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 InputVecType,
typename OutputVecType>
66 static void Fn(
const InputVecType& x, OutputVecType& y)
70 for (
size_t i = 0; i < x.n_elem; i++)
80 static double Deriv(
const double y)
82 return 1.0 / (1 + std::exp(-y));
91 template<
typename InputVecType,
typename OutputVecType>
92 static void Deriv(
const InputVecType& y, OutputVecType& x)
94 x = 1.0 / (1 + arma::exp(-y));
103 static double Inv(
const double y)
105 return y > 0 ? arma::trunc_log(arma::trunc_exp(y) - 1) : 0;
114 template<
typename InputVecType,
typename OutputVecType>
115 static void Inv(
const InputVecType& y, OutputVecType& x)
119 for (
size_t i = 0; i < y.n_elem; i++)
static void Fn(const InputVecType &x, OutputVecType &y)
Computes 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 void Deriv(const InputVecType &y, OutputVecType &x)
Computes the first derivatives of the softplus function.
static double Fn(const double x)
Computes the softplus function.
static void Inv(const InputVecType &y, OutputVecType &x)
Computes the inverse of the softplus function.
The softplus function, defined by.
static double Inv(const double y)
Computes the inverse of the softplus function.