12 #ifndef MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_LOGISTIC_FUNCTION_HPP 13 #define MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_LOGISTIC_FUNCTION_HPP 39 static double fn(
const eT x)
41 if (x < arma::Datum<eT>::log_max)
43 if (x > -arma::Datum<eT>::log_max)
44 return 1.0 / (1.0 + std::exp(-x));
58 template<
typename InputVecType,
typename OutputVecType>
59 static void fn(
const InputVecType& x, OutputVecType& y)
61 y = (1.0 / (1 + arma::exp(-x)));
70 static double deriv(
const double y)
81 template<
typename InputVecType,
typename OutputVecType>
82 static void deriv(
const InputVecType& y, OutputVecType& x)
93 static double inv(
const double y)
95 return arma::trunc_log(y / (1 - y));
104 template<
typename InputVecType,
typename OutputVecType>
105 static void inv(
const InputVecType& y, OutputVecType& x)
107 x = arma::trunc_log(y / (1 - y));
Linear algebra utility functions, generally performed on matrices or vectors.
static double inv(const double y)
Computes the inverse of the logistic function.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static double deriv(const double y)
Computes the first derivative of the logistic function.
static void inv(const InputVecType &y, OutputVecType &x)
Computes the inverse of the logistic function.
The logistic function, defined by.
static void deriv(const InputVecType &y, OutputVecType &x)
Computes the first derivatives of the logistic function.
static double fn(const eT x)
Computes the logistic function.
static void fn(const InputVecType &x, OutputVecType &y)
Computes the logistic function.