27 #ifndef TMVA_DNN_DLMINIMIZERS 28 #define TMVA_DNN_DLMINIMIZERS 64 template <
typename Architecture_t>
68 using Scalar_t =
typename Architecture_t::Scalar_t;
69 using Matrix_t =
typename Architecture_t::Matrix_t;
92 fMinimumError = std::numeric_limits<Scalar_t>::infinity();
93 fConvergenceCount = 0;
163 template <
typename Architecture_t>
172 template <
typename Architecture_t>
182 template <
typename Architecture_t>
188 deepNet.
Backward(input, output, weights);
193 template <
typename Architecture_t>
199 deepNet.
Backward(input, output, weights);
201 for (
size_t i = 0; i < deepNet.
GetDepth(); i++) {
204 layer->UpdateWeights(layer->GetWeightGradients(),
fLearningRate);
206 layer->UpdateBiases(layer->GetBiasGradients(),
fLearningRate);
212 template <
typename Architecture_t>
217 deepNet.Backward(input,
output, weights);
224 template <
typename Architecture_t>
231 deepNet.Backward(input,
output, weights);
233 for (
size_t i = 0; i < deepNet.GetDepth(); i++) {
234 auto *layer = deepNet.GetLayerAt(i);
236 layer->UpdateWeights(layer->GetWeightGradients(),
fLearningRate);
238 layer->UpdateBiases(layer->GetBiasGradients(),
fLearningRate);
246 template <
typename Architecture_t>
256 template <
typename Architecture_t>
266 template <
typename Architecture_t>
276 template <
typename Architecture_t>
290 template <
typename Architecture_t>
void StepReducedWeights(DeepNet_t &deepNet, std::vector< Matrix_t > &input, const Matrix_t &output, const Matrix_t &weights)
Does not evaluate the loss and therefore not trigger a possible synchronization with the device...
size_t GetConvergenceSteps() const
void SetConvergenceSteps(size_t steps)
Setters.
void ParallelBackward(std::vector< TDeepNet< Architecture_t, Layer_t >> &nets, std::vector< TTensorBatch< Architecture_t >> &batches, Scalar_t learningRate)
Function for parallel backward in the vector of deep nets, where the master net is the net calling th...
void SetLearningRate(Scalar_t rate)
void Step(DeepNet_t &deepNet, std::vector< Matrix_t > &input, const Matrix_t &output, const Matrix_t &weights)
Perform a single optimization step on a given batch.
Scalar_t fLearningRate
Learning rate .
bool HasConverged()
Increases the minimization step counter by the test error evaluation period and uses the current inte...
void SetTestInterval(size_t interval)
void Forward(std::vector< Matrix_t > &input, bool applyDropout=false)
Function that executes the entire forward pass in the network.
Scalar_t StepLoss(DeepNet_t &deepNet, std::vector< Matrix_t > &input, const Matrix_t &output, const Matrix_t &weights)
Same as Step(...) but also evaluate the loss on the given training data.
Scalar_t fMinimumError
The minimum loss achieved on the training set.
Layer_t * GetLayerAt(size_t i)
Get the layer in the vector of layers at poistion i.
size_t GetTestInterval() const
Scalar_t GetTrainingError() const
void ParallelBackwardMomentum(std::vector< TDeepNet< Architecture_t, Layer_t >> &nets, std::vector< TTensorBatch< Architecture_t >> &batches, Scalar_t learningRate, Scalar_t momentum)
Function for parallel backward in the vector of deep nets, where the master net is the net calling th...
size_t GetConvergenceCount() const
Getters.
void Backward(std::vector< Matrix_t > &input, const Matrix_t &groundTruth, const Matrix_t &weights)
Function that executes the entire backward pass in the network.
void ParallelBackwardNestorov(std::vector< TDeepNet< Architecture_t, Layer_t >> &nets, std::vector< TTensorBatch< Architecture_t >> &batches, Scalar_t learningRate, Scalar_t momentum)
Function for parallel backward in the vector of deep nets, where the master net is the net calling th...
Scalar_t fTestError
Holds the most recently computed test loss.
Scalar_t GetTestError() const
void ParallelForward(std::vector< TDeepNet< Architecture_t, Layer_t >> &nets, std::vector< TTensorBatch< Architecture_t >> &batches, bool applyDropout=false)
Function for parallel forward in the vector of deep nets, where the master net is the net calling thi...
size_t fBatchSize
Batch size to use for the training.
size_t fConvergenceSteps
Number of training epochs without considerable.
void StepMomentum(DeepNet_t &master, std::vector< DeepNet_t > &nets, std::vector< TTensorBatch< Architecture_t >> &batches, Scalar_t momentum)
Same as the Step(...) method for multiple batches but uses momentum.
size_t fStepCount
Number of steps performed in the current training session.
void Reset()
Reset minimizer object to default state.
void Update(Scalar_t learningRate)
Function that will update the weights and biases in the layers that contain weights and biases...
Abstract ClassifierFactory template that handles arbitrary types.
void SetBatchSize(Scalar_t rate)
void StepNesterov(DeepNet_t &master, std::vector< DeepNet_t > &nets, std::vector< TTensorBatch< Architecture_t >> &batches, Scalar_t momentum)
Same as the Step(...) method for multiple batches but uses Nesterov momentum.
typename Architecture_t::Matrix_t Matrix_t
typename Architecture_t::Scalar_t Scalar_t
Scalar_t fTrainingError
Holds the most recently computed training loss.
size_t fConvergenceCount
Current number of training epochs without.
size_t fTestInterval
Interval for the computation of the test error.
Scalar_t StepReducedWeightsLoss(DeepNet_t &deepNet, std::vector< Matrix_t > &input, const Matrix_t &output, const Matrix_t &weights)
Similar to StepReducedWeights(...) but also evaluates the loss.
Generic Deep Neural Network class.