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)