mlpack  master
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(y.n_elem);
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 
90 
91 }; // class IdentityFunction
92 
93 } // namespace ann
94 } // namespace mlpack
95 
96 #endif
The identity function, defined by.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
The core includes that mlpack expects; standard C++ includes and Armadillo.
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 void fn(const InputVecType &x, OutputVecType &y)
Computes the identity function.
static void deriv(const InputVecType &y, OutputVecType &x)
Computes the first derivatives of the identity function.
static double fn(const double x)
Computes the identity function.
static double deriv(const double)
Computes the first derivative of the identity function.