25 #ifndef MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_SOFTSIGN_FUNCTION_HPP 26 #define MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_SOFTSIGN_FUNCTION_HPP 56 static double Fn(
const double x)
59 return x > -DBL_MAX ? x / (1.0 + std::abs(x)) : -1.0;
69 template<
typename InputVecType,
typename OutputVecType>
70 static void Fn(
const InputVecType& x, OutputVecType& y)
72 y.set_size(arma::size(x));
74 for (
size_t i = 0; i < x.n_elem; ++i)
84 static double Deriv(
const double y)
86 return std::pow(1.0 - std::abs(y), 2);
95 template<
typename InputVecType,
typename OutputVecType>
96 static void Deriv(
const InputVecType& y, OutputVecType& x)
98 x = arma::pow(1.0 - arma::abs(y), 2);
107 static double Inv(
const double y)
110 return y < 1 ? -y / (y - 1) : DBL_MAX;
112 return y > -1 ? y / (1 + y) : -DBL_MAX;
121 template<
typename InputVecType,
typename OutputVecType>
122 static void Inv(
const InputVecType& y, OutputVecType& x)
124 x.set_size(arma::size(y));
126 for (
size_t i = 0; i < y.n_elem; ++i)
static double Inv(const double y)
Computes the inverse of the softsign function.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static void Fn(const InputVecType &x, OutputVecType &y)
Computes the softsign function.
static void Deriv(const InputVecType &y, OutputVecType &x)
Computes the first derivatives of the softsign function.
static void Inv(const InputVecType &y, OutputVecType &x)
Computes the inverse of the softsign function.
static double Fn(const double x)
Computes the softsign function.
static double Deriv(const double y)
Computes the first derivative of the softsign function.
The softsign function, defined by.