43template <
typename Architecture_t,
typename Layer_t = VGeneralLayer<Architecture_t>,
44 typename DeepNet_t = TDeepNet<Architecture_t, Layer_t>>
47 using Matrix_t =
typename Architecture_t::Matrix_t;
48 using Scalar_t =
typename Architecture_t::Scalar_t;
101template <
typename Architecture_t,
typename Layer_t,
typename DeepNet_t>
107 std::vector<Layer_t *> &layers =
deepNet.GetLayers();
140template <
typename Architecture_t,
typename Layer_t,
typename DeepNet_t>
152 Scalar_t alpha = (this->GetLearningRate()) * (sqrt(1 - pow(this->GetBeta2(), this->GetGlobalStep()))) /
153 (1 - pow(this->GetBeta1(), this->GetGlobalStep()));
156 for (
size_t i = 0; i < weights.size(); i++) {
163 alpha, this->GetEpsilon() );
168template <
typename Architecture_t,
typename Layer_t,
typename DeepNet_t>
176 Scalar_t alpha = (this->GetLearningRate()) * (sqrt(1 - pow(this->GetBeta2(), this->GetGlobalStep()))) /
177 (1 - pow(this->GetBeta1(), this->GetGlobalStep()));
180 for (
size_t i = 0; i <
biases.size(); i++) {
187 alpha, this->GetEpsilon() );
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
std::vector< std::vector< Matrix_t > > fSecondMomentWeights
The decaying average of the second moment of the past weight gradients associated with the deep net.
std::vector< Matrix_t > & GetSecondMomentBiasesAt(size_t i)
Scalar_t GetEpsilon() const
typename Architecture_t::Matrix_t Matrix_t
std::vector< Matrix_t > & GetFirstMomentBiasesAt(size_t i)
Scalar_t fBeta2
The Beta2 constant used by the optimizer.
std::vector< std::vector< Matrix_t > > fSecondMomentBiases
The decaying average of the second moment of the past bias gradients associated with the deep net.
std::vector< std::vector< Matrix_t > > & GetSecondMomentBiases()
~TAdam()=default
Destructor.
std::vector< Matrix_t > & GetFirstMomentWeightsAt(size_t i)
std::vector< std::vector< Matrix_t > > & GetSecondMomentWeights()
Scalar_t GetBeta2() const
std::vector< std::vector< Matrix_t > > fFirstMomentBiases
The decaying average of the first moment of the past bias gradients associated with the deep net.
Scalar_t fEpsilon
The Smoothing term used to avoid division by zero.
void UpdateWeights(size_t layerIndex, std::vector< Matrix_t > &weights, const std::vector< Matrix_t > &weightGradients)
Update the weights, given the current weight gradients.
std::vector< std::vector< Matrix_t > > & GetFirstMomentWeights()
TAdam(DeepNet_t &deepNet, Scalar_t learningRate=0.001, Scalar_t beta1=0.9, Scalar_t beta2=0.999, Scalar_t epsilon=1e-7)
Constructor.
std::vector< Matrix_t > & GetSecondMomentWeightsAt(size_t i)
std::vector< std::vector< Matrix_t > > fFirstMomentWeights
The decaying average of the first moment of the past weight gradients associated with the deep net.
Scalar_t fBeta1
The Beta1 constant used by the optimizer.
void UpdateBiases(size_t layerIndex, std::vector< Matrix_t > &biases, const std::vector< Matrix_t > &biasGradients)
Update the biases, given the current bias gradients.
std::vector< std::vector< Matrix_t > > & GetFirstMomentBiases()
typename Architecture_t::Scalar_t Scalar_t
Scalar_t GetBeta1() const
Getters.
create variable transformations