26 #ifndef MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_SOFTPLUS_FUNCTION_HPP 27 #define MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_SOFTPLUS_FUNCTION_HPP 53 static double fn(
const double x)
56 return x > -DBL_MAX ? std::log(1 + std::exp(x)) : 0;
66 template<
typename InputVecType,
typename OutputVecType>
67 static void fn(
const InputVecType& x, OutputVecType& y)
71 for (
size_t i = 0; i < x.n_elem; i++)
81 static double deriv(
const double y)
83 return 1.0 / (1 + std::exp(-y));
92 template<
typename InputVecType,
typename OutputVecType>
93 static void deriv(
const InputVecType& y, OutputVecType& x)
95 x = 1.0 / (1 + arma::exp(-y));
104 static double inv(
const double y)
106 return y > 0 ? arma::trunc_log(arma::trunc_exp(y) - 1) : 0;
115 template<
typename InputVecType,
typename OutputVecType>
116 static void inv(
const InputVecType& y, OutputVecType& x)
120 for (
size_t i = 0; i < y.n_elem; i++)
Linear algebra utility functions, generally performed on matrices or vectors.
static double fn(const double x)
Computes the softplus function.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static double inv(const double y)
Computes the inverse of the softplus function.
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 softplus function, defined by.
static void inv(const InputVecType &y, OutputVecType &x)
Computes the inverse of the softplus function.
static void deriv(const InputVecType &y, OutputVecType &x)
Computes the first derivatives of the softplus function.