silu_function.hpp
Go to the documentation of this file.
1 
27 #ifndef MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_SILU_FUNCTION_HPP
28 #define MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_SILU_FUNCTION_HPP
29 
30 #include <mlpack/prereqs.hpp>
31 
32 namespace mlpack {
33 namespace ann /* Artificial Neural Network */ {
34 
44 {
45  public:
52  static double Fn(const double x)
53  {
54  return x / (1.0 + std::exp(-x));
55  }
56 
63  template<typename InputVecType, typename OutputVecType>
64  static void Fn(const InputVecType &x, OutputVecType &y)
65  {
66  y = x / (1.0 + arma::exp(-x));
67  }
68 
75  static double Deriv(const double x)
76  {
77  double sigmoid = 1.0 / (1.0 + std::exp(-x));
78  return sigmoid * (1.0 + x * (1.0 - sigmoid));
79  }
80 
87  template<typename InputVecType, typename OutputVecType>
88  static void Deriv(const InputVecType &x, OutputVecType &y)
89  {
90  OutputVecType sigmoid = 1.0 / (1.0 + arma::exp(-x));
91  y = sigmoid % (1.0 + x % (1.0 - sigmoid));
92  }
93 }; // class SILUFunction
94 
95 } // namespace ann
96 } // namespace mlpack
97 
98 #endif
static double Fn(const double x)
Computes the SILU function.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static double Deriv(const double x)
Computes the first derivative of the SILU function.
The SILU function, defined by.
static void Fn(const InputVecType &x, OutputVecType &y)
Computes the SILU function.
static void Deriv(const InputVecType &x, OutputVecType &y)
Computes the first derivatives of the SILU function.