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;
208 #include "layer_norm_impl.hpp" OutputDataType Mean()
Get the mean across single training data.
OutputDataType const & OutputParameter() const
Get the output parameter.
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Linear algebra utility functions, generally performed on matrices or vectors.
size_t InSize() const
Get the number of input units.
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType const & Delta() const
Get the delta.
OutputDataType & Parameters()
Modify the parameters.
LayerNorm()
Create the LayerNorm object.
OutputDataType & OutputParameter()
Modify the output parameter.
OutputDataType & Delta()
Modify the delta.
Declaration of the Layer Normalization class.
OutputDataType & Gradient()
Modify the gradient.
double Epsilon() const
Get the value of epsilon.
OutputDataType const & Parameters() const
Get the parameters.
OutputDataType Variance()
Get the variance across single training data.
OutputDataType const & Gradient() const
Get the gradient.
void Backward(const arma::Mat< eT > &input, const arma::Mat< eT > &gy, arma::Mat< eT > &g)
Backward pass through the layer.
void Forward(const arma::Mat< eT > &input, arma::Mat< eT > &output)
Forward pass of Layer Normalization.
void Reset()
Reset the layer parameters.
size_t InputShape() const
Get the shape of the input.