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))) /
static void Fn(const InputVecType &x, OutputVecType &y)
Computes the swish function.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static double Fn(const double x)
Computes the swish function.
static double Deriv(const double y)
Computes the first derivative of the swish function.
static void Deriv(const InputVecType &y, OutputVecType &x)
Computes the first derivatives of the swish function.
The swish function, defined by.
static void Fn(const arma::Mat< eT > &x, arma::Mat< eT > &y)
Computes the swish function using a matrix as input.