mlpack  3.4.2
elish_function.hpp
Go to the documentation of this file.
1 
26 #ifndef MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_ELISH_FUNCTION_HPP
27 #define MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_ELISH_FUNCTION_HPP
28 
29 #include <mlpack/prereqs.hpp>
30 
31 namespace mlpack {
32 namespace ann {
33 
49 {
50  public:
57  static double Fn(const double x)
58  {
59  if (x < 0.0)
60  return (std::exp(x) - 1) / (1 + std::exp(-x));
61 
62  return x / (1 + std::exp(-x));
63  }
64 
71  template<typename InputVecType, typename OutputVecType>
72  static void Fn(const InputVecType& x, OutputVecType& y)
73  {
74  y = ((x < 0.0) % ((arma::exp(x) -1) / (1 + arma::exp(-x))))
75  + ((x >= 0.0) % (x / (1 + arma::exp(-x))));
76  }
77 
84  static double Deriv(const double y)
85  {
86  if (y < 0.0)
87  {
88  return std::exp(y) - 2 / (1 + std::exp(y)) +
89  2 / std::pow(1 + std::exp(y) , 2);
90  }
91 
92  return 1 / (1 + std::exp(-y)) + y * std::exp(-y) /
93  std::pow(1 + std::exp(-y) , 2);
94  }
95 
102  template<typename InputVecType, typename OutputVecType>
103  static void Deriv(const InputVecType& y, OutputVecType& x)
104  {
105  x = ((y < 0.0) % (arma::exp(y) - 2 / (1 + arma::exp(y)) + 2 / arma::pow(
106  1 + arma::exp(y), 2))) + ((y >= 0.0) % (1 / (1 + arma::exp(-y)) + y %
107  arma::exp(-y) / arma::pow(1 + arma::exp(-y), 2)));
108  }
109 }; // class ElishFunction
110 
111 } // namespace ann
112 } // namespace mlpack
113 
114 #endif
The ELiSH function, defined by.
static double Fn(const double x)
Computes the ELiSH function.
static double Deriv(const double y)
Computes the first derivatives of ELiSH function.
static void Deriv(const InputVecType &y, OutputVecType &x)
Computes the first derivatives of the ELiSH function.
static void Fn(const InputVecType &x, OutputVecType &y)
Computes the ELiSH function.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.