Declaration of the Batch Normalization layer class. More...
Public Member Functions | |
BatchNorm () | |
Create the BatchNorm object. More... | |
BatchNorm (const size_t size, const double eps=1e-8) | |
Create the BatchNorm layer object for a specified number of input units. More... | |
template < typename eT > | |
void | Backward (const arma::Mat< eT > &&input, arma::Mat< eT > &&gy, arma::Mat< eT > &&g) |
Backward pass through the layer. More... | |
OutputDataType const & | Delta () const |
Get the delta. More... | |
OutputDataType & | Delta () |
Modify the delta. More... | |
bool | Deterministic () const |
Get the value of deterministic parameter. More... | |
bool & | Deterministic () |
Modify the value of deterministic parameter. More... | |
template < typename eT > | |
void | Forward (const arma::Mat< eT > &&input, arma::Mat< eT > &&output) |
Forward pass of the Batch Normalization layer. More... | |
template < typename eT > | |
void | Gradient (const arma::Mat< eT > &&input, arma::Mat< eT > &&error, arma::Mat< eT > &&gradient) |
Calculate the gradient using the output delta and the input activations. More... | |
OutputDataType const & | Gradient () const |
Get the gradient. More... | |
OutputDataType & | Gradient () |
Modify the gradient. More... | |
OutputDataType const & | OutputParameter () const |
Get the output parameter. More... | |
OutputDataType & | OutputParameter () |
Modify the output parameter. More... | |
OutputDataType const & | Parameters () const |
Get the parameters. More... | |
OutputDataType & | Parameters () |
Modify the parameters. More... | |
void | Reset () |
Reset the layer parameters. More... | |
template < typename Archive > | |
void | serialize (Archive &ar, const unsigned int) |
Serialize the layer. More... | |
OutputDataType | TrainingMean () |
Get the mean over the training data. More... | |
OutputDataType | TrainingVariance () |
Get the variance over the training data. More... | |
Declaration of the Batch Normalization layer class.
The layer transforms the input data into zero mean and unit variance and then scales and shifts the data by parameters, gamma and beta respectively. These parameters are learnt by the network.
If deterministic is false (training), the mean and variance over the batch is calculated and the data is normalized. If it is set to true (testing) then the mean and variance accrued over the training set is used.
For more information, refer to the following paper,
InputDataType | Type of the input data (arma::colvec, arma::mat, arma::sp_mat or arma::cube). |
OutputDataType | Type of the output data (arma::colvec, arma::mat, arma::sp_mat or arma::cube). |
Definition at line 56 of file batch_norm.hpp.
BatchNorm | ( | const size_t | size, |
const double | eps = 1e-8 |
||
) |
Create the BatchNorm layer object for a specified number of input units.
size | The number of input units. |
eps | The epsilon added to variance to ensure numerical stability. |
void Backward | ( | const arma::Mat< eT > && | input, |
arma::Mat< eT > && | gy, | ||
arma::Mat< eT > && | g | ||
) |
Backward pass through the layer.
input | The input activations |
gy | The backpropagated error. |
g | The calculated gradient. |
|
inline |
Get the delta.
Definition at line 121 of file batch_norm.hpp.
|
inline |
Modify the delta.
Definition at line 123 of file batch_norm.hpp.
|
inline |
Get the value of deterministic parameter.
Definition at line 131 of file batch_norm.hpp.
|
inline |
Modify the value of deterministic parameter.
Definition at line 133 of file batch_norm.hpp.
void Forward | ( | const arma::Mat< eT > && | input, |
arma::Mat< eT > && | output | ||
) |
Forward pass of the Batch Normalization layer.
Transforms the input data into zero mean and unit variance, scales the data by a factor gamma and shifts it by beta.
input | Input data for the layer |
output | Resulting output activations. |
void Gradient | ( | const arma::Mat< eT > && | input, |
arma::Mat< eT > && | error, | ||
arma::Mat< eT > && | gradient | ||
) |
Calculate the gradient using the output delta and the input activations.
input | The input activations |
error | The calculated error |
gradient | The calculated gradient. |
|
inline |
Get the gradient.
Definition at line 126 of file batch_norm.hpp.
|
inline |
Modify the gradient.
Definition at line 128 of file batch_norm.hpp.
|
inline |
Get the output parameter.
Definition at line 116 of file batch_norm.hpp.
|
inline |
Modify the output parameter.
Definition at line 118 of file batch_norm.hpp.
|
inline |
Get the parameters.
Definition at line 111 of file batch_norm.hpp.
|
inline |
Modify the parameters.
Definition at line 113 of file batch_norm.hpp.
void Reset | ( | ) |
Reset the layer parameters.
void serialize | ( | Archive & | ar, |
const unsigned | int | ||
) |
Serialize the layer.
Referenced by BatchNorm< InputDataType, OutputDataType >::TrainingVariance().
|
inline |
Get the mean over the training data.
Definition at line 136 of file batch_norm.hpp.
|
inline |
Get the variance over the training data.
Definition at line 139 of file batch_norm.hpp.
References BatchNorm< InputDataType, OutputDataType >::serialize().