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)
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
static double Fn(const double x)
Computes the softsign function.
Definition: softsign_function.hpp:56
The core includes that mlpack expects; standard C++ includes and Armadillo.
static double Deriv(const double y)
Computes the first derivative of the softsign function.
Definition: softsign_function.hpp:84
static void Inv(const InputVecType &y, OutputVecType &x)
Computes the inverse of the softsign function.
Definition: softsign_function.hpp:122
static void Deriv(const InputVecType &y, OutputVecType &x)
Computes the first derivatives of the softsign function.
Definition: softsign_function.hpp:96
static double Inv(const double y)
Computes the inverse of the softsign function.
Definition: softsign_function.hpp:107
static void Fn(const InputVecType &x, OutputVecType &y)
Computes the softsign function.
Definition: softsign_function.hpp:70
The softsign function, defined by.
Definition: softsign_function.hpp:47