26 #ifndef MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_SOFTPLUS_FUNCTION_HPP 27 #define MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_SOFTPLUS_FUNCTION_HPP 52 static double Fn(
const double x)
55 return x > -DBL_MAX ? std::log(1 + std::exp(x)) : 0;
65 template<
typename InputType,
typename OutputType>
66 static void Fn(
const InputType& x, OutputType& y)
69 y.transform([](
double val) {
return (
Fn(val));} );
78 static double Deriv(
const double y)
80 return 1.0 / (1 + std::exp(-y));
89 template<
typename InputType,
typename OutputType>
90 static void Deriv(
const InputType& y, OutputType& x)
92 x = 1.0 / (1 + arma::exp(-y));
101 static double Inv(
const double y)
103 return y > 0 ? arma::trunc_log(arma::trunc_exp(y) - 1) : 0;
112 template<
typename InputType,
typename OutputType>
113 static void Inv(
const InputType& y, OutputType& x)
116 x.transform([](
double val) {
return (
Inv(val));} );
static void Deriv(const InputType &y, OutputType &x)
Computes the first derivatives of the softplus function.
static void Fn(const InputType &x, OutputType &y)
Computes the softplus function.
static void Inv(const InputType &y, OutputType &x)
Computes the inverse of the softplus function.
static double Deriv(const double y)
Computes the first derivative of the softplus function.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static double Fn(const double x)
Computes the softplus function.
The softplus function, defined by.
static double Inv(const double y)
Computes the inverse of the softplus function.