identity_function.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_IDENTITY_FUNCTION_HPP
13 #define MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_IDENTITY_FUNCTION_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace ann {
19 
29 {
30  public:
37  static double Fn(const double x)
38  {
39  return x;
40  }
41 
48  template<typename InputVecType, typename OutputVecType>
49  static void Fn(const InputVecType& x, OutputVecType& y)
50  {
51  y = x;
52  }
53 
60  static double Deriv(const double /* unused */)
61  {
62  return 1.0;
63  }
64 
71  template<typename InputVecType, typename OutputVecType>
72  static void Deriv(const InputVecType& y, OutputVecType& x)
73  {
74  x.ones(arma::size(y));
75  }
76 
84  template<typename eT>
85  static void Deriv(const arma::Cube<eT>& y, arma::Cube<eT>& x)
86  {
87  x.ones(y.n_rows, y.n_cols, y.n_slices);
88  }
89 }; // class IdentityFunction
90 
91 } // namespace ann
92 } // namespace mlpack
93 
94 #endif
The identity function, defined by.
static void Deriv(const InputVecType &y, OutputVecType &x)
Computes the first derivatives of the identity function.
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
static void Fn(const InputVecType &x, OutputVecType &y)
Computes the identity function.
static double Deriv(const double)
Computes the first derivative of the identity function.
static void Deriv(const arma::Cube< eT > &y, arma::Cube< eT > &x)
Computes the first derivatives of the identity function using a 3rd order tensor as input...
static double Fn(const double x)
Computes the identity function.