70 virtual void prop(
void) =0;
77 std::cout <<
"Pool Rate: " << N_block << std::endl;
78 std::cout <<
"Stride: " << N_stride << std::endl;
90 void upsamp2(
const arma::Mat<DNN_Dtype>& Src, arma::Mat<DNN_Dtype>& Dst,arma::uword N)
92 const arma::uword Rin = Src.n_rows;
93 const arma::uword Cin = Src.n_cols;
97 for (arma::uword c=0 ; c<Cin ; c++ )
99 for (arma::uword k=0 ; k<N ; k++ )
101 for (arma::uword r=0 ; r<Rin ; r++ )
104 for (arma::uword n=0 ; n<N ; n++ )
120 void upsamp2(
const arma::Cube<DNN_Dtype>& Src,arma::Cube<DNN_Dtype>& Dst,
const arma::uword N)
122 for (arma::uword l=0 ; l<Src.n_slices ; l++ )
124 upsamp2(Src.slice(l),Dst.slice(l),N);
172 for (arma::uword ir = 0; ir <
N_block; ir++)
174 for (arma::uword ic = 0; ic <
N_block; ic++)
176 DNN_Dtype px = Src.at(r + ir, c + ic, l);
200 for (arma::uword n = 0; n <
N_batch; n++)
210 arma::uword r_offs=0, c_offs=0;
212 for (arma::uword ir = 0; ir <
N_block; ir++)
214 for (arma::uword ic = 0; ic <
N_block; ic++)
241 for (arma::uword n=0; n<
N_batch; n++)
284 for (arma::uword l=0 ; l<Src_cube.n_slices; l++ )
286 arma::Mat<DNN_Dtype> Src_mat=Src_cube.slice(l);
287 arma::Mat<DNN_Dtype> mask_mat(arma::size(Src_mat),arma::fill::zeros);
292 arma::Mat<DNN_Dtype> dd=Src_mat(r,c,arma::size(N_block,N_block));
293 Dst(r/N_block,c/N_block) = dd.max();
296 Y1.rows(l*Dst.n_elem,(l+1)*Dst.n_elem-1) =
mat2mat(Dst,Dst.n_elem,1);
310 for (arma::uword n = 0; n <
N_batch; n++)
321 for (arma::uword ir = 0; ir <
N_block; ir++)
323 for (arma::uword ic = 0; ic <
N_block; ic++)
325 av += Src.at(r+ir, c+ic, l);
344 for (arma::uword n=0; n<
N_batch; n++)
virtual void init(void)
Initialize layer.
std::string type
Layer type string.
void prop_mb(void)
Forward mini batch propagation though layer.
virtual void prop(void)=0
Forward propagation.
arma::Mat< DNN_Dtype > Y
Output buffer mini batch [N_right,N_batch].
arma::uword N_rows_left
Input rows.
layer * right
Pointer to next layer.
void prop(void)
Forward propagation though layer.
arma::uword N_channels_right
Output channels, number of filters.
arma_inline arma::Mat< DNN_Dtype > mat2mat(const arma::Mat< DNN_Dtype > &A, const arma::uword rows, const arma::uword cols)
Reshapes a matrix.
arma::Mat< DNN_Dtype > Dleft
Error buffer [N_left,N_batch].
arma::Mat< DNN_Dtype > mask
Pooling mask.
void prop(void)
Forward propagation though layer.
virtual void backprop(void)=0
Back propagation.
virtual void upd_buf_size(arma::uword nmb)
Update layer buffer sizes.
arma::uword N_cols_left
Input cols.
arma::Mat< DNN_Dtype > Y1
Output buffer [N_right,1].
virtual void prop_mb(void)=0
Forward propagation - mini batch.
virtual DNN_Dtype * get_Y_colptr(const arma::uword n)
Get output buffer memory column pointer - mini batch.
virtual arma::uword get_nrof_outputs(void)
Get total number of layer outputs.
pool_average(const arma::uword n_block)
Average pooling layer constructor.
virtual arma::Mat< DNN_Dtype > get_Y1(void)
Get output buffer.
virtual void init(void)
Initialize layer.
arma_inline arma::Mat< DNN_Dtype > cube2mat(arma::Cube< DNN_Dtype > &A, const arma::uword rows, const arma::uword cols)
Converts a cube to a matrix.
virtual arma::uword get_nrof_channels(void)
Get output buffer channel/layer size.
arma::uword N_stride
Stride.
virtual void disp(void)
Display info about layer.
float DNN_Dtype
Data type used in the network (float or double)
void backprop(void)
Backpropagation of mini batch propagation though layer.
arma::uword N_left
Total size left.
arma::uword N_rows_right
Output rows.
void upsamp2(const arma::Mat< DNN_Dtype > &Src, arma::Mat< DNN_Dtype > &Dst, arma::uword N)
2D upsampling
virtual void upd_buf_size(arma::uword nmb)
Update layer buffer sizes.
virtual void disp(void)
Display info about layer.
virtual arma::uword get_nrof_cols(void)
Get output buffer column size.
arma::uword N_batch
Mini batch size.
void upsamp2(const arma::Cube< DNN_Dtype > &Src, arma::Cube< DNN_Dtype > &Dst, const arma::uword N)
2D upsampling for Cube
arma::uword N_block
Pooling block size.
void prop_mb(void)
Forward mini batch propagation though layer.
Average pooling layer class.
arma::uword N_channels_left
Input channels, number of filters.
pool_max(const arma::uword n_block)
Max pooling layer constructor.
virtual arma::uword get_nrof_rows(void)
Get output buffer row size.
arma::uword N_right
Total size right.
virtual DNN_Dtype * get_Y1_memptr(void)
Get output buffer memory pointer.
layer * left
Pointer to previous layer.
arma::uword N_cols_right
Output cols.
Pooling layer base class.
layer_pool(const arma::uword n_block)
Pooling layer constructor.
void backprop(void)
Backpropagation of mini batch propagation though layer.
virtual DNN_Dtype * get_Dleft_colptr(const arma::uword n)
Get error buffer memory column pointer - mini batch.