mlpack  master
gradient_visitor.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_ANN_VISITOR_GRADIENT_VISITOR_HPP
14 #define MLPACK_METHODS_ANN_VISITOR_GRADIENT_VISITOR_HPP
15 
18 
19 #include <boost/variant.hpp>
20 
21 namespace mlpack {
22 namespace ann {
23 
28 class GradientVisitor : public boost::static_visitor<void>
29 {
30  public:
33  GradientVisitor(arma::mat&& input, arma::mat&& delta);
34 
36  template<typename LayerType>
37  void operator()(LayerType* layer) const;
38 
39  private:
41  arma::mat&& input;
42 
44  arma::mat&& delta;
45 
48  template<typename T>
49  typename std::enable_if<
50  HasGradientCheck<T, arma::mat&(T::*)()>::value, void>::type
51  LayerGradients(T* layer, arma::mat& input) const;
52 
55  template<typename T, typename P>
56  typename std::enable_if<
57  !HasGradientCheck<T, P&(T::*)()>::value, void>::type
58  LayerGradients(T* layer, P& input) const;
59 };
60 
61 } // namespace ann
62 } // namespace mlpack
63 
64 // Include implementation.
65 #include "gradient_visitor_impl.hpp"
66 
67 #endif
arma::mat && input
The input set.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
void operator()(LayerType *layer) const
Executes the Gradient() method.
std::enable_if< HasGradientCheck< T, arma::mat &(T::*)()>::value, void >::type LayerGradients(T *layer, arma::mat &input) const
Execute the Gradient() function if the module implements the Gradient() function. ...
GradientVisitor(arma::mat &&input, arma::mat &&delta)
Executes the Gradient() method of the given module using the input and delta parameter.
arma::mat && delta
The delta parameter.
SearchModeVisitor executes the Gradient() method of the given module using the input and delta parame...