12 #ifndef MLPACK_METHODS_ANN_LAYER_LAYERNORM_HPP 13 #define MLPACK_METHODS_ANN_LAYER_LAYERNORM_HPP 62 typename InputDataType = arma::mat,
63 typename OutputDataType = arma::mat
77 LayerNorm(
const size_t size,
const double eps = 1e-8);
93 void Forward(
const arma::Mat<eT>& input, arma::Mat<eT>& output);
102 template<
typename eT>
103 void Backward(
const arma::Mat<eT>& input,
104 const arma::Mat<eT>& gy,
114 template<
typename eT>
115 void Gradient(
const arma::Mat<eT>& input,
116 const arma::Mat<eT>& error,
117 arma::Mat<eT>& gradient);
130 OutputDataType
const&
Delta()
const {
return delta; }
132 OutputDataType&
Delta() {
return delta; }
135 OutputDataType
const&
Gradient()
const {
return gradient; }
140 OutputDataType
Mean() {
return mean; }
160 template<
typename Archive>
161 void serialize(Archive& ar,
const uint32_t );
174 OutputDataType gamma;
180 OutputDataType weights;
186 OutputDataType variance;
189 OutputDataType gradient;
192 OutputDataType delta;
195 OutputDataType outputParameter;
198 OutputDataType normalized;
201 OutputDataType inputMean;
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: layer_norm.hpp:125
OutputDataType Mean()
Get the mean across single training data.
Definition: layer_norm.hpp:140
OutputDataType & Gradient()
Modify the gradient.
Definition: layer_norm.hpp:137
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
double Epsilon() const
Get the value of epsilon.
Definition: layer_norm.hpp:149
OutputDataType const & Gradient() const
Get the gradient.
Definition: layer_norm.hpp:135
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType & Delta()
Modify the delta.
Definition: layer_norm.hpp:132
void Forward(const arma::Mat< eT > &input, arma::Mat< eT > &output)
Forward pass of Layer Normalization.
Definition: layer_norm_impl.hpp:59
size_t InSize() const
Get the number of input units.
Definition: layer_norm.hpp:146
OutputDataType const & Delta() const
Get the delta.
Definition: layer_norm.hpp:130
void Backward(const arma::Mat< eT > &input, const arma::Mat< eT > &gy, arma::Mat< eT > &g)
Backward pass through the layer.
Definition: layer_norm_impl.hpp:80
Declaration of the Layer Normalization class.
Definition: layer_norm.hpp:65
void Reset()
Reset the layer parameters.
Definition: layer_norm_impl.hpp:43
OutputDataType & Parameters()
Modify the parameters.
Definition: layer_norm.hpp:122
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: layer_norm.hpp:127
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: layer_norm_impl.hpp:121
LayerNorm()
Create the LayerNorm object.
Definition: layer_norm_impl.hpp:24
size_t InputShape() const
Get the shape of the input.
Definition: layer_norm.hpp:152
OutputDataType Variance()
Get the variance across single training data.
Definition: layer_norm.hpp:143
OutputDataType const & Parameters() const
Get the parameters.
Definition: layer_norm.hpp:120