26 void forward(Eigen::MatrixXd &out,
const Eigen::MatrixXd &x)
override
30 out = 1 / (1 + (-x).array().exp());
32 _forward_output = out;
41 void backward(Eigen::MatrixXd &out,
const Eigen::MatrixXd &dx)
override
43 out = _forward_output.array() * (1 - _forward_output.array()) * dx.array();
47 Eigen::MatrixXd _forward_output;
Base class for all activation functions.
Definition Activation.hpp:24
Eigen::MatrixXd _forward_input
Definition Activation.hpp:37
Sigmoid activation function.
Definition Sigmoid.hpp:13
Sigmoid()
Construct a new Sigmoid object.
Definition Sigmoid.hpp:18
void forward(Eigen::MatrixXd &out, const Eigen::MatrixXd &x) override
Forward pass of the sigmoid activation function.
Definition Sigmoid.hpp:26
void backward(Eigen::MatrixXd &out, const Eigen::MatrixXd &dx) override
Backward pass of the sigmoid activation function.
Definition Sigmoid.hpp:41
Definition Activation.hpp:6
ActivationType
Enum class for activation types.
Definition Activation.hpp:11