Quantcast
Channel: Math.NET Numerics
Viewing all articles
Browse latest Browse all 971

New Post: Can this be done faster?

$
0
0
Yes, this could be a bit faster. I've measured the quoted part (average on 100 repetitions) on my system with random data of the same size. Compiled in release mode, without debugger attached (hence outside VisualStudio).
  • As quoted: 0.367s
  • When I compile explicitly for the x64 platform target: 0.217s
  • With in-place addition: 0.202s
DeltaEncoder.Add(NeuronError.Column(col).OuterProduct(InputWithBias.Column(col)), DeltaEncoder)
  • With Intel MKL/x64 native provider: 0.135s
' Install MathNet.Numerics.MKL.Win-x64 NuGet package (beware: may required license from Intel)
Control.UseNativeMKL
Then, it seems the OuterProduct operation was missed when all the vector-vector operations have been refactored in the early v3 works. Because of this it does not come with a proper inplace version. I've fixed this in master, will be part of the next release greater than v3.0.0-beta02. With this change you can change the loop as follows:
DeltaEncoder.Clear();
var work = Matrix<double>.Build.Dense(DeltaEncoder.RowCount, DeltaEncoder.ColumnCount);
for (int col = 0; col < NumberOfObs; col++)
{
    NeuronError.Column(col).OuterProduct(InputWithBias.Column(col), work);
    DeltaEncoder.Add(work, DeltaEncoder);
}
DeltaEncoder /= NumberOfObs;
  • Managed: 0.124s
  • With MKL: 0.059s
Still not very fast but quite a bit better. Do you get similar numbers?

Thanks,
Christoph

Viewing all articles
Browse latest Browse all 971

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>