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  GradientVisitor(arma::mat&& input, arma::mat&& delta, const size_t index);
37 
39  template<typename LayerType>
40  void operator()(LayerType* layer) const;
41 
42  private:
44  arma::mat&& input;
45 
47  arma::mat&& delta;
48 
50  size_t index;
51 
53  bool hasIndex;
54 
57  template<typename T>
58  typename std::enable_if<
59  HasGradientCheck<T, arma::mat&(T::*)()>::value &&
60  !HasRunCheck<T, bool&(T::*)(void)>::value, void>::type
61  LayerGradients(T* layer, arma::mat& input) const;
62 
65  template<typename T>
66  typename std::enable_if<
67  HasGradientCheck<T, arma::mat&(T::*)()>::value &&
68  HasRunCheck<T, bool&(T::*)(void)>::value, void>::type
69  LayerGradients(T* layer, arma::mat& input) const;
70 
73  template<typename T, typename P>
74  typename std::enable_if<
75  !HasGradientCheck<T, P&(T::*)()>::value, void>::type
76  LayerGradients(T* layer, P& input) const;
77 };
78 
79 } // namespace ann
80 } // namespace mlpack
81 
82 // Include implementation.
83 #include "gradient_visitor_impl.hpp"
84 
85 #endif
.hpp
Definition: add_to_po.hpp:21
SearchModeVisitor executes the Gradient() method of the given module using the input and delta parame...
void operator()(LayerType *layer) const
Executes the Gradient() method.
GradientVisitor(arma::mat &&input, arma::mat &&delta)
Executes the Gradient() method of the given module using the input and delta parameter.