23 #ifndef SRC_MLNN_SIGMOID_HPP_
24 #define SRC_MLNN_SIGMOID_HPP_
30 namespace activation_function {
36 template <
typename eT=
float>
44 Sigmoid(
size_t size_,std::string name_ =
"Sigmoid") :
58 Sigmoid(
size_t height_,
size_t width_,
size_t depth_,
59 std::string name_ =
"Sigmoid") :
61 height_, width_, depth_,
74 eT* x =
s[
'x']->data();
75 eT* y =
s[
'y']->data();
77 for (
size_t i = 0; i < (size_t)
s[
'x']->rows() *
s[
'x']->cols(); i++) {
78 y[i] = 1.0f / (1.0f +::exp(-x[i]));
84 eT* gx =
g[
'x']->data();
85 eT* gy =
g[
'y']->data();
86 eT* y =
s[
'y']->data();
88 for (
size_t i = 0; i < (size_t)
g[
'x']->rows() *
g[
'x']->cols(); i++) {
90 gx[i] = gy[i]* (y[i] * (1.0 - y[i]));
99 virtual void update(eT alpha_, eT decay_ = 0.0f) { };
Sigmoid(size_t height_, size_t width_, size_t depth_, std::string name_="Sigmoid")
Class representing a multi-layer neural network.
LayerTypes
Enumeration of possible layer types.
virtual void update(eT alpha_, eT decay_=0.0f)
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.
Sigmoid(size_t size_, std::string name_="Sigmoid")
void forward(bool test=false)
Contains a template class representing a layer.