110 arma::Cube<DNN_Dtype> a(arma::size(
W));
119 arma::Mat<DNN_Dtype> m={1.0};
153 arma::Mat<DNN_Dtype>
weights2img(
const arma::uword R,
const arma::uword C)
155 const arma::uword Nimg =
W.slice(0).n_elem/(R*C);
156 const arma::uword PR =
static_cast<arma::uword
>(floor(sqrt(Nimg)));
157 const arma::uword PC =
static_cast<arma::uword
>(ceil(Nimg/(1.0*PR)));
158 arma::Mat<DNN_Dtype> ZZ(PR*R,PC*C,arma::fill::zeros);
160 arma::Col<DNN_Dtype> Iv=arma::vectorise(
W.slice(0).t());
164 for(arma::uword m=0; m<Nimg; m++)
166 const arma::Mat<DNN_Dtype> Z(iptr,R,C);
168 ZZ(r,c,arma::size(R,C)) = Z+
B(m);
void prop(void)
Forward propagation though layer.
opt * opt_alg
Pointer to optimizer.
std::string type
Layer type string.
arma::Mat< DNN_Dtype > Y
Output buffer mini batch [N_right,N_batch].
void update(void)
Updates the trainable parameters.
layer * right
Pointer to next layer.
arma::uword N_channels_right
Output channels, number of filters.
arma::Mat< DNN_Dtype > weights2img(const arma::uword R, const arma::uword C)
Generate an image of the weights.
arma::Mat< DNN_Dtype > Dleft
Error buffer [N_left,N_batch].
layer_dense(const arma::uword n_rows)
Dense layer constructor.
arma::Mat< DNN_Dtype > Y1
Output buffer [N_right,1].
void prop_mb(void)
Forward mini batch propagation though layer.
virtual arma::uword get_nrof_inputs(void)
Get total number of layer inputs.
void init_weights(T &w, arma::uword fan_in, arma::uword fan_out, INIT_W_ALG alg, INIT_W_DIST dist)
Initiate weights.
virtual arma::uword get_nrof_outputs(void)
Get total number of layer outputs.
virtual arma::Mat< DNN_Dtype > get_Y1(void)
Get output buffer.
virtual void init(void)
Initialize layer.
void init(void)
Initialization of layer.
void disp(void)
Display info about layer.
arma::Mat< DNN_Dtype > B
Bias.
virtual arma::Mat< DNN_Dtype > * get_Dleft_ptr(void)
Get error buffer pointer - mini batch.
arma::uword get_nrof_params(void)
Get info about number of trainable parameters in layer.
virtual void disp(void)
Display info about layer.
float DNN_Dtype
Data type used in the network (float or double)
arma::uword N_left
Total size left.
arma::uword N_rows_right
Output rows.
virtual void apply(arma::Cube< DNN_Dtype > &W, arma::Mat< DNN_Dtype > &B, const arma::Cube< DNN_Dtype > &Wgrad, const arma::Mat< DNN_Dtype > &Bgrad)=0
Apply the optimizer to the layer parameters.
arma::Cube< DNN_Dtype > W
Weights.
void backprop(void)
Backpropagation of mini batch propagation though layer.
arma::uword N_batch
Mini batch size.
bool train_par
Enable training.
virtual std::string get_algorithm(void)
Get the optimizer algorithm information.
arma::uword N_right
Total size right.
layer * left
Pointer to previous layer.
arma::uword N_cols_right
Output cols.
A fully connected/dense layer class.
virtual arma::Mat< DNN_Dtype > * get_Y_ptr(void)
Get output buffer pointer - mini batch.
bool add_bias
Enable bias.