13 #ifndef MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_SWISH_FUNCTION_HPP
14 #define MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_SWISH_FUNCTION_HPP
39 static double Fn(
const double x)
41 return x / (1.0 + std::exp(-x));
51 static void Fn(
const arma::Mat<eT>& x, arma::Mat<eT>& y)
53 y = x / (1.0 + arma::exp(-x));
62 template<
typename InputVecType,
typename OutputVecType>
63 static void Fn(
const InputVecType& x, OutputVecType& y)
65 y.set_size(arma::size(x));
67 for (
size_t i = 0; i < x.n_elem; ++i)
77 static double Deriv(
const double y)
79 return y / (1 + std::exp(-y)) + (1 - y / (1 + std::exp(-y))) /
89 template<
typename InputVecType,
typename OutputVecType>
90 static void Deriv(
const InputVecType& y, OutputVecType& x)
92 x = y / (1 + arma::exp(-y)) + (1 - y / (1 + arma::exp(-y))) /