23 #ifndef SRC_MLNN_ELU_HPP_
24 #define SRC_MLNN_ELU_HPP_
30 namespace activation_function {
38 template <
typename eT=
float>
47 ELU(
size_t size_,std::string name_ =
"ELU") :
48 ELU(size_, 1, 1, name_)
61 ELU(
size_t height_,
size_t width_,
size_t depth_, std::string name_ =
"ELU") :
63 height_, width_, depth_,
76 eT* x =
s[
'x']->data();
77 eT* y =
s[
'y']->data();
80 size_t size = (size_t)
s[
'x']->rows() *
s[
'x']->cols();
81 for (
size_t i = 0; i < size; i++) {
82 y[i] = x[i] > 0.0f ? x[i] : (expf(x[i]) - 1.0f);
88 eT* gx =
g[
'x']->data();
89 eT* gy =
g[
'y']->data();
90 eT* y =
s[
'y']->data();
93 size_t size = (size_t)
g[
'x']->rows() *
g[
'x']->cols();
94 for (
size_t i = 0; i < size; i++) {
96 eT dy = y[i] > 0.0f ? 1.0f : exp(y[i]);
108 virtual void update(eT alpha_, eT decay_ = 0.0f) { };
Class implementing the layer with Exponential Linear Unit (ELU). http://arxiv.org/pdf/1511.07289v5.pdf.
Class representing a multi-layer neural network.
ELU(size_t height_, size_t width_, size_t depth_, std::string name_="ELU")
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.
void forward(bool test=false)
virtual void update(eT alpha_, eT decay_=0.0f)
Contains a template class representing a layer.
ELU(size_t size_, std::string name_="ELU")