mlpack 3.4.2
mish_function.hpp
Go to the documentation of this file.
1
23#ifndef MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_MISH_FUNCTION_HPP
24#define MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_MISH_FUNCTION_HPP
25
26#include <mlpack/prereqs.hpp>
27#include <algorithm>
28
29namespace mlpack {
30namespace ann {
31
41{
42 public:
49 static double Fn(const double x)
50 {
51 return x * (std::exp(2 * x) + 2 * std::exp(x)) /
52 (2 + 2 * std::exp(x) + std::exp(2 * x));
53 }
54
61 template <typename InputVecType, typename OutputVecType>
62 static void Fn(const InputVecType &x, OutputVecType &y)
63 {
64 y = x % (arma::exp(2 * x) + 2 * arma::exp(x)) /
65 (2 + 2 * arma::exp(x) + arma::exp(2 * x));
66 }
67
74 static double Deriv(const double y)
75 {
76 return std::exp(y) * (4 * (y + 1) + std::exp(y) * (4 * y + 6) +
77 4 * std::exp(2 * y) + std::exp(3 * y)) /
78 std::pow(std::exp(2 * y) + 2 * std::exp(y) + 2, 2);
79 }
80
87 template <typename InputVecType, typename OutputVecType>
88 static void Deriv(const InputVecType &y, OutputVecType &x)
89 {
90 x = arma::exp(y) % (4 * (y + 1) + arma::exp(y) % (4 * y + 6) +
91 4 * arma::exp(2 * y) + arma::exp(3 * y)) /
92 arma::pow(arma::exp(2 * y) + 2 * arma::exp(y) + 2, 2);
93 }
94}; // class MishFunction
95
96} // namespace ann
97} // namespace mlpack
98
99#endif
The Mish function, defined by.
static double Fn(const double x)
Computes the Mish function.
static double Deriv(const double y)
Computes the first derivative of the Mish function.
static void Deriv(const InputVecType &y, OutputVecType &x)
Computes the first derivatives of the Mish function.
static void Fn(const InputVecType &x, OutputVecType &y)
Computes the Mish function.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.