12 void forward(Eigen::MatrixXd &out,
const Eigen::MatrixXd &x)
override
16 out = x.array().tanh();
18 _forward_output = out;
21 void backward(Eigen::MatrixXd &out,
const Eigen::MatrixXd &dx)
override
23 out = (1.0 - _forward_output.array().square()) * dx.array();
27 Eigen::MatrixXd _forward_output;
Base class for all activation functions.
Definition Activation.hpp:24
Eigen::MatrixXd _forward_input
Definition Activation.hpp:37
void forward(Eigen::MatrixXd &out, const Eigen::MatrixXd &x) override
Forward pass of the layer.
Definition Tanh.hpp:12
void backward(Eigen::MatrixXd &out, const Eigen::MatrixXd &dx) override
Backward pass of the layer.
Definition Tanh.hpp:21
Tanh()
Definition Tanh.hpp:10
Definition Activation.hpp:6
ActivationType
Enum class for activation types.
Definition Activation.hpp:11