DaNNet
Public Member Functions | Private Attributes | List of all members
dnn::layer_norm Class Reference

Batch normalization layer class. More...

#include <dnn_layer_norm.h>

Inheritance diagram for dnn::layer_norm:
dnn::layer

Public Member Functions

 layer_norm (void)
 
void init (void)
 Initialization of layer. More...
 
void upd_buf_size (arma::uword nmb)
 Updates the buffer sizes. More...
 
void set_run_mean (arma::Mat< DNN_Dtype > &r_mean)
 Set the running mean matrix. More...
 
void set_run_var (arma::Mat< DNN_Dtype > &r_var)
 Set the running variance matrix. More...
 
arma::uword get_nrof_params (void)
 Get info about number of trainable parameters in layer. More...
 
void prop (void)
 Forward propagation though layer. More...
 
void prop_mb (void)
 Forward mini batch propagation though layer. More...
 
void backprop (void)
 Backpropagation of mini batch propagation though layer. More...
 
void update (void)
 Updates the trainable parameters. More...
 
void disp (void)
 Display info about layer. More...
 
- Public Member Functions inherited from dnn::layer
 layer (void)
 Layer constructor. More...
 
 ~layer ()
 
virtual void enable_training (void)
 Enable training of layer. More...
 
virtual void disable_training (void)
 Disable training of layer. More...
 
virtual void enable_bias (void)
 Enable bias term in layer. More...
 
virtual void disable_bias (void)
 Disable bias term in layer. More...
 
virtual arma::Mat< DNN_Dtypeget_B (void)
 Get bias. More...
 
virtual arma::Cube< DNN_Dtypeget_W (void)
 Get weights. More...
 
virtual void set_B (arma::Mat< DNN_Dtype > &b)
 Set bias. More...
 
virtual void set_W (arma::Cube< DNN_Dtype > &w)
 Set weights. More...
 
virtual void set_phase (PHASE p)
 Set phase/state. More...
 
virtual void set_left (layer *lptr)
 Set pointer to left layer. More...
 
virtual void set_right (layer *rptr)
 Set pointer to right layer. More...
 
virtual void set_id (const std::string str)
 Set layer id string. More...
 
virtual std::string get_id (void)
 Get layer id string. More...
 
virtual void set_type (const std::string str)
 Set layer type string. More...
 
virtual std::string get_type (void)
 Get layer type string. More...
 
virtual void set_ix (const arma::uword n)
 Set layer index. More...
 
virtual arma::uword get_ix (void)
 Get layer index. More...
 
virtual void set_batch_size (const arma::uword n)
 Set mini batch size. More...
 
virtual arma::uword get_batch_size (void)
 Get mini batch size. More...
 
virtual void set_Y1 (arma::Mat< DNN_Dtype > &y)
 Set output buffer. More...
 
virtual void set_Y (arma::Mat< DNN_Dtype > &y)
 Set output buffer - mini batch. More...
 
virtual void set_Dleft (arma::Mat< DNN_Dtype > &d)
 Set error output buffer - mini batch. More...
 
virtual void set_rows_in (arma::uword r)
 Set input buffer row size. More...
 
virtual arma::uword get_nrof_rows (void)
 Get output buffer row size. More...
 
virtual void set_cols_in (arma::uword c)
 Set input buffer column size. More...
 
virtual arma::uword get_nrof_cols (void)
 Get output buffer column size. More...
 
virtual void set_channels_in (arma::uword l)
 Set input buffer channel/layer size. More...
 
virtual arma::uword get_nrof_channels (void)
 Get output buffer channel/layer size. More...
 
virtual void set_opt_alg (opt &alg_class)
 Set pointer to optimizer class. More...
 
virtual optget_opt_alg (void)
 Get pointer to optimizer class. More...
 
virtual arma::uword get_nrof_inputs (void)
 Get total number of layer inputs. More...
 
virtual arma::uword get_nrof_outputs (void)
 Get total number of layer outputs. More...
 
virtual arma::Mat< DNN_Dtypeget_Y1 (void)
 Get output buffer. More...
 
virtual arma::Mat< DNN_Dtype > * get_Y1_ptr (void)
 Get output buffer pointer. More...
 
virtual DNN_Dtypeget_Y1_memptr (void)
 Get output buffer memory pointer. More...
 
virtual arma::Mat< DNN_Dtypeget_Y (void)
 Get output buffer - mini batch. More...
 
virtual arma::Mat< DNN_Dtype > * get_Y_ptr (void)
 Get output buffer pointer - mini batch. More...
 
virtual DNN_Dtypeget_Y_memptr (void)
 Get output buffer memory pointer - mini batch. More...
 
virtual DNN_Dtypeget_Y_colptr (const arma::uword n)
 Get output buffer memory column pointer - mini batch. More...
 
virtual arma::Mat< DNN_Dtypeget_Dleft ()
 Get error buffer - mini batch. More...
 
virtual arma::Mat< DNN_Dtype > * get_Dleft_ptr (void)
 Get error buffer pointer - mini batch. More...
 
virtual DNN_Dtypeget_Dleft_memptr (void)
 Get error buffer memory pointer - mini batch. More...
 
virtual DNN_Dtypeget_Dleft_colptr (const arma::uword n)
 Get error buffer memory column pointer - mini batch. More...
 
virtual void save_layer_param (std::string name, PARAM_FORMAT f=PARAM_FORMAT::ASCII)
 Save layer weight and bias. More...
 
virtual void load_layer_param (std::string name, PARAM_FORMAT f=PARAM_FORMAT::AUTO)
 Load layer weight and bias. More...
 
template<typename T >
void init_weights (T &w, arma::uword fan_in, arma::uword fan_out, INIT_W_ALG alg, INIT_W_DIST dist)
 Initiate weights. More...
 
DNN_Dtype sigmoid (const DNN_Dtype x)
 Sigmoid function - scalar. More...
 
arma::Mat< DNN_Dtypesigmoid (const arma::Mat< DNN_Dtype > &x)
 Sigmoid function - matrix. More...
 
arma::Mat< DNN_Dtypesoftmax (const arma::Mat< DNN_Dtype > &x)
 Softmax function - matrix. More...
 

Private Attributes

arma::Mat< DNN_Dtypegamma
 
arma::Mat< DNN_Dtypebeta
 
arma::Mat< DNN_Dtypex_mean
 
arma::Mat< DNN_Dtypex_stdinv
 
arma::Mat< DNN_Dtypex_norm
 
arma::Mat< DNN_Dtypeee
 
arma::Mat< DNN_Dtyperun_mean
 
arma::Mat< DNN_Dtyperun_var
 
DNN_Dtype run_alpha
 

Additional Inherited Members

- Protected Attributes inherited from dnn::layer
layerleft
 Pointer to previous layer. More...
 
layerright
 Pointer to next layer. More...
 
std::string id
 Layer id string. More...
 
std::string type
 Layer type string. More...
 
arma::uword layer_ix
 Layer index [0..]. More...
 
bool train_par
 Enable training. More...
 
bool add_bias
 Enable bias. More...
 
optopt_alg
 Pointer to optimizer. More...
 
PHASE phase
 Active state/phase. More...
 
arma::uword N_batch
 Mini batch size. More...
 
arma::uword N_rows_left
 Input rows. More...
 
arma::uword N_cols_left
 Input cols. More...
 
arma::uword N_channels_left
 Input channels, number of filters. More...
 
arma::uword N_rows_right
 Output rows. More...
 
arma::uword N_cols_right
 Output cols. More...
 
arma::uword N_channels_right
 Output channels, number of filters. More...
 
arma::uword N_left
 Total size left. More...
 
arma::uword N_right
 Total size right. More...
 
arma::Mat< DNN_DtypeY
 Output buffer mini batch [N_right,N_batch]. More...
 
arma::Mat< DNN_DtypeY1
 Output buffer [N_right,1]. More...
 
arma::Mat< DNN_DtypeDleft
 Error buffer [N_left,N_batch]. More...
 
arma::Cube< DNN_DtypeW
 Weights. More...
 
arma::Mat< DNN_DtypeB
 Bias. More...
 

Detailed Description

Batch normalization layer class.

Implements batch normalization layer

Definition at line 29 of file dnn_layer_norm.h.

Constructor & Destructor Documentation

◆ layer_norm()

dnn::layer_norm::layer_norm ( void  )
inline

Definition at line 42 of file dnn_layer_norm.h.

Member Function Documentation

◆ backprop()

void dnn::layer_norm::backprop ( void  )
inlinevirtual

Backpropagation of mini batch propagation though layer.

Performas a error backpropagation mini batch pass through layer

Reimplemented from dnn::layer.

Definition at line 151 of file dnn_layer_norm.h.

◆ disp()

void dnn::layer_norm::disp ( void  )
inlinevirtual

Display info about layer.

Reimplemented from dnn::layer.

Definition at line 183 of file dnn_layer_norm.h.

◆ get_nrof_params()

arma::uword dnn::layer_norm::get_nrof_params ( void  )
inlinevirtual

Get info about number of trainable parameters in layer.

Returns
Number of trainable parameters

Reimplemented from dnn::layer.

Definition at line 104 of file dnn_layer_norm.h.

◆ init()

void dnn::layer_norm::init ( void  )
inlinevirtual

Initialization of layer.

Calculates the output and internal buffer sizes and initializes the parameters

Reimplemented from dnn::layer.

Definition at line 48 of file dnn_layer_norm.h.

◆ prop()

void dnn::layer_norm::prop ( void  )
inlinevirtual

Forward propagation though layer.

Performas a forward pass through layer

Reimplemented from dnn::layer.

Definition at line 114 of file dnn_layer_norm.h.

◆ prop_mb()

void dnn::layer_norm::prop_mb ( void  )
inlinevirtual

Forward mini batch propagation though layer.

Performas a forward mini batch pass through layer

Reimplemented from dnn::layer.

Definition at line 125 of file dnn_layer_norm.h.

◆ set_run_mean()

void dnn::layer_norm::set_run_mean ( arma::Mat< DNN_Dtype > &  r_mean)
inline

Set the running mean matrix.

Parameters
[in]r_meanRunning mean matrix

Definition at line 86 of file dnn_layer_norm.h.

◆ set_run_var()

void dnn::layer_norm::set_run_var ( arma::Mat< DNN_Dtype > &  r_var)
inline

Set the running variance matrix.

Parameters
[in]r_varRunning variance matrix

Definition at line 95 of file dnn_layer_norm.h.

◆ upd_buf_size()

void dnn::layer_norm::upd_buf_size ( arma::uword  nmb)
inlinevirtual

Updates the buffer sizes.

Parameters
[in]nmbNew mini batch buffer size

Updates and clears the buffer sizes, called when size of mini batch is changed

Reimplemented from dnn::layer.

Definition at line 75 of file dnn_layer_norm.h.

◆ update()

void dnn::layer_norm::update ( void  )
inlinevirtual

Updates the trainable parameters.

Calculates the gradients and update the trainiable parameters

Reimplemented from dnn::layer.

Definition at line 165 of file dnn_layer_norm.h.

Member Data Documentation

◆ beta

arma::Mat<DNN_Dtype> dnn::layer_norm::beta
private

Definition at line 33 of file dnn_layer_norm.h.

◆ ee

arma::Mat<DNN_Dtype> dnn::layer_norm::ee
private

Definition at line 37 of file dnn_layer_norm.h.

◆ gamma

arma::Mat<DNN_Dtype> dnn::layer_norm::gamma
private

Definition at line 32 of file dnn_layer_norm.h.

◆ run_alpha

DNN_Dtype dnn::layer_norm::run_alpha
private

Definition at line 40 of file dnn_layer_norm.h.

◆ run_mean

arma::Mat<DNN_Dtype> dnn::layer_norm::run_mean
private

Definition at line 38 of file dnn_layer_norm.h.

◆ run_var

arma::Mat<DNN_Dtype> dnn::layer_norm::run_var
private

Definition at line 39 of file dnn_layer_norm.h.

◆ x_mean

arma::Mat<DNN_Dtype> dnn::layer_norm::x_mean
private

Definition at line 34 of file dnn_layer_norm.h.

◆ x_norm

arma::Mat<DNN_Dtype> dnn::layer_norm::x_norm
private

Definition at line 36 of file dnn_layer_norm.h.

◆ x_stdinv

arma::Mat<DNN_Dtype> dnn::layer_norm::x_stdinv
private

Definition at line 35 of file dnn_layer_norm.h.


The documentation for this class was generated from the following file: