17 #ifndef TMVA_DNN_LAYER 18 #define TMVA_DNN_LAYER 51 template<
typename Architecture_t>
56 using Scalar_t =
typename Architecture_t::Scalar_t;
57 using Matrix_t =
typename Architecture_t::Matrix_t;
100 const Matrix_t & activations_backward,
144 template<
typename Architecture_t>
150 using Scalar_t =
typename Architecture_t::Scalar_t;
151 using Matrix_t =
typename Architecture_t::Matrix_t;
188 const Matrix_t & activations_backward,
222 template<
typename Architecture_t>
238 template<
typename Architecture_t>
255 template<
typename Architecture_t>
264 template<
typename Architecture_t>
279 template<
typename Architecture_t>
281 const Matrix_t & activations_backward,
286 Architecture_t::Backward(gradients_backward,
292 activations_backward);
299 template<
typename Architecture_t>
302 std::cout <<
"Width = " <<
fWeights.GetNrows();
303 std::cout <<
", Activation Function = ";
304 std::cout << static_cast<int>(
fF) << std::endl;
313 template<
typename Architecture_t>
328 template<
typename Architecture_t>
341 template<
typename Architecture_t>
356 template<
typename Architecture_t>
358 const Matrix_t & activations_backward,
363 Architecture_t::Backward(gradients_backward,
369 activations_backward);
376 template<
typename Architecture_t>
379 std::cout <<
"Width = " <<
fWeights.GetNrows();
380 std::cout <<
", Activation Function = ";
381 std::cout << static_cast<int>(
fF) << std::endl;
void Forward(Matrix_t &input, bool applyDropout=false)
Compute activation of the layer for the given input.
EActivationFunction fF
Activation function of the layer.
Matrix_t fWeightGradients
Gradients w.r.t. the weigths of this layer.
void SetDropoutProbability(Scalar_t p)
TLayer(size_t BatchSize, size_t InputWidth, size_t Width, EActivationFunction f, Scalar_t dropoutProbability)
EActivationFunction GetActivationFunction() const
size_t fInputWidth
Number of neurons of the previous layer.
size_t fBatchSize
Batch size used for training and evaluation.
void Backward(Matrix_t &gradients_backward, const Matrix_t &activations_backward, ERegularization r, Scalar_t weightDecay)
Compute weight, bias and activation gradients.
TSharedLayer(size_t fBatchSize, TLayer< Architecture_t > &layer)
size_t GetDropoutProbability() const
Matrix_t & GetWeights() const
size_t GetDropoutProbability() const
Matrix_t fOutput
Activations of this layer.
const Matrix_t & GetOutput() const
const Matrix_t & GetBiasGradients() const
Matrix_t & GetWeightGradients()
EActivationFunction fF
Activation function of the layer.
Matrix_t fDerivatives
First fDerivatives of the activations of this layer.
const Matrix_t & GetBiases() const
const Matrix_t & GetBiases() const
Matrix_t fBiasGradients
Gradients w.r.t. the bias values of this layer.
Matrix_t & fBiases
Reference to the bias vectors of this layer.
Matrix_t fWeightGradients
Gradients w.r.t. the weigths of this layer.
Matrix_t fWeights
The fWeights of this layer.
double weightDecay(double error, ItWeight itWeight, ItWeight itWeightEnd, double factorWeightDecay, EnumRegularization eRegularization)
compute the weight decay for regularization (L1 or L2)
size_t fInputWidth
Number of neurons of the previous layer.
Matrix_t & GetBiasGradients()
Matrix_t & GetWeightGradients()
const Matrix_t & GetActivationGradients() const
typename Architecture_t::Scalar_t Scalar_t
typename Architecture_t::Scalar_t Scalar_t
Matrix_t fBiases
The bias values of this layer.
Matrix_t fBiasGradients
Gradients w.r.t. the bias values of this layer.
size_t GetInputWidth() const
Matrix_t & GetActivationGradients()
EActivationFunction GetActivationFunction() const
Matrix_t & GetActivationGradients()
typename Architecture_t::Matrix_t Matrix_t
size_t GetInputWidth() const
size_t GetBatchSize() const
Matrix_t fOutput
Activations of this layer.
Scalar_t fDropoutProbability
Probability that an input is active.
Matrix_t & fWeights
Reference to the weight matrix of this layer.
Matrix_t & GetBiasGradients()
const Matrix_t & GetOutput() const
const Matrix_t & GetWeightGradients() const
size_t fBatchSize
Batch size used for training and evaluation.
void Forward(Matrix_t &input, bool applyDropout=false)
Compute activation of the layer for the given input.
void Initialize(EInitialization m)
Initialize fWeights according to the given initialization method.
void SetDropoutProbability(Scalar_t p)
void Copy(void *source, void *dest)
Layer class width shared weight and bias layers.
Matrix_t fDerivatives
First fDerivatives of the activations of this layer.
const Matrix_t & GetActivationGradients() const
size_t fWidth
Number of neurons of this layer.
Matrix_t fActivationGradients
Gradients w.r.t. the activations of this layer.
Scalar_t fDropoutProbability
Probability that an input is active.
typename Architecture_t::Matrix_t Matrix_t
Abstract ClassifierFactory template that handles arbitrary types.
Matrix_t fActivationGradients
Gradients w.r.t. the activations of this layer.
size_t GetBatchSize() const
ERegularization
Enum representing the regularization type applied for a given layer.
const Matrix_t & GetWeights() const
const Matrix_t & GetBiasGradients() const
EActivationFunction
Enum that represents layer activation functions.
void Backward(Matrix_t &gradients_backward, const Matrix_t &activations_backward, ERegularization r, Scalar_t weightDecay)
Compute weight, bias and activation gradients.
size_t fWidth
Number of neurons of this layer.
const Matrix_t & GetWeightGradients() const