23 #ifndef SRC_MLNN_RELU_HPP_
24 #define SRC_MLNN_RELU_HPP_
30 namespace activation_function {
36 template <
typename eT=
float>
45 ReLU(
size_t size_, std::string name_ =
"ReLU") :
46 ReLU(size_, 1, 1, name_)
48 std::cout<<
"constructor ReLU 1!\n";
59 ReLU(
size_t height_,
size_t width_,
size_t depth_, std::string name_ =
"ReLU") :
61 height_, width_, depth_,
72 void forward(
bool apply_dropout =
false) {
74 eT* x =
s[
'x']->data();
75 eT* y =
s[
'y']->data();
78 size_t size =
s[
'x']->rows() *
s[
'x']->cols();
79 for (
size_t i = 0; i < size; i++) {
80 y[i] = fmax(x[i], 0.0f);
89 eT* gx =
g[
'x']->data();
90 eT* gy =
g[
'y']->data();
91 eT* y =
s[
'y']->data();
94 size_t size =
g[
'x']->rows() *
g[
'x']->cols();
95 for (
size_t i = 0; i < size; i++) {
97 eT dy = (eT)(y[i] > 0.0);
112 virtual void update(eT alpha_, eT decay_ = 0.0f) { };
virtual void update(eT alpha_, eT decay_=0.0f)
ReLU(size_t height_, size_t width_, size_t depth_, std::string name_="ReLU")
void forward(bool apply_dropout=false)
ReLU(size_t size_, std::string name_="ReLU")
Class representing a multi-layer neural network.
LayerTypes
Enumeration of possible layer types.
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.