23 #ifndef SRC_MLNN_DROPOUT_HPP_
24 #define SRC_MLNN_DROPOUT_HPP_
30 namespace regularisation {
38 template <
typename eT=
float>
45 Dropout<eT>(
size_t inputs_,
float ratio_, std::string name_ =
"Dropout") :
52 m.add (
"random", inputs_, inputs_);
53 m.add (
"dropout_mask", inputs_, inputs_);
74 (*
s[
'y']) = (*
s[
'x']);
78 mic::types::MatrixPtr<eT> batch_x =
s[
'x'];
79 mic::types::MatrixPtr<eT> batch_y =
s[
'y'];
82 mic::types::MatrixPtr<eT> rand =
m[
"random"];
83 rand->rand(0.0f, 1.0f);
86 mic::types::MatrixPtr<eT> mask =
m[
"dropout_mask"];
88 #pragma omp parallel for
89 for(
size_t i=0; i< (size_t)mask->size(); i++)
93 (*batch_y) = (*mask) * (*batch_x);
103 mic::types::MatrixPtr<eT> batch_dx =
g[
'x'];
104 mic::types::MatrixPtr<eT> batch_dy =
g[
'y'];
105 mic::types::MatrixPtr<eT> mask =
m[
"dropout_mask"];
108 (*batch_dy) = (*mask).transpose() * (*batch_dx);
116 virtual void update(eT alpha_, eT decay_ = 0.0f) { };
virtual void resizeBatch(size_t batch_size_)
Droput layer - a layer used for the regularization of neural network by randomly dropping neurons dur...
virtual void resizeBatch(size_t batch_size_)
virtual void update(eT alpha_, eT decay_=0.0f)
void forward(bool test=false)
Class representing a multi-layer neural network.
mic::types::MatrixArray< eT > s
States - contains input [x] and output [y] matrices.
mic::types::MatrixArray< eT > g
Gradients - contains input [x] and output [y] matrices.
Contains a template class representing a layer.
mic::types::MatrixArray< eT > m
Memory - a list of temporal parameters, to be used by the derived classes.