33 template <
typename Architecture>
35 ->
typename Architecture::Scalar_t
37 using Matrix_t =
typename Architecture::Matrix_t;
40 size_t nSamples = 10000;
41 size_t nFeatures = 20;
42 size_t batchSize = 256;
45 XTest(batchSize, nFeatures), YTest(batchSize, 1), W(nFeatures, 1);
50 YTrain.Mult(XTrain, W);
63 minimizer.
TrainMomentum(trainingData, nSamples, testData, batchSize, net, 0.8, 1);
66 for (
size_t i = 0; i < nFeatures; i++) {
70 auto clone = net.CreateClone(nFeatures);
79 template <
typename Architecture>
81 ->
typename Architecture::Scalar_t
83 using Matrix_t =
typename Architecture::Matrix_t;
86 size_t nSamples = 10000;
87 size_t nFeatures = 20;
88 size_t batchSize = 256;
91 XTest(batchSize, nFeatures), YTest(batchSize, 1), W(nFeatures, 1);
96 YTrain.Mult(XTrain, W);
109 minimizer.
TrainMomentum(trainingData, nSamples, testData, batchSize, net, 0.9, 1);
112 for (
size_t i = 0; i < nFeatures; i++) {
116 auto clone = net.CreateClone(nFeatures);
auto maximumRelativeError(const Matrix1 &X, const Matrix2 &Y) -> decltype(X(0, 0))
Compute the maximum, element-wise relative error of the matrices X and Y normalized by the element of...
void randomMatrix(AMatrix &X)
Fill matrix with random, Gaussian-distributed values.
Scalar_t TrainMomentum(const Data_t &TrainingDataIn, size_t nTrainingSamples, const Data_t &TestDataIn, size_t nTestSamples, Net_t &net, Scalar_t momentum, size_t nThreads=1)
Same as Train(...) but uses the given momentum.
Generic neural network class.
auto testMinimization() -> typename Architecture::Scalar_t
Train a linear neural network on a randomly generated linear mapping from a 20-dimensional input spac...
auto testMinimizationMomentum() -> typename Architecture::Scalar_t
Similar to testMinimization() as the function above except that it uses momentum for the training...
std::pair< const TMatrixT< Double_t > &, const TMatrixT< Double_t > & > MatrixInput_t