weight_set_visitor.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_ANN_VISITOR_WEIGHT_SET_VISITOR_HPP
14 #define MLPACK_METHODS_ANN_VISITOR_WEIGHT_SET_VISITOR_HPP
15 
17 
18 #include <boost/variant.hpp>
19 
20 namespace mlpack {
21 namespace ann {
22 
26 class WeightSetVisitor : public boost::static_visitor<size_t>
27 {
28  public:
30  WeightSetVisitor(arma::mat&& weight, const size_t offset = 0);
31 
33  template<typename LayerType>
34  size_t operator()(LayerType* layer) const;
35 
36  size_t operator()(MoreTypes layer) const;
37 
38  private:
40  arma::mat&& weight;
41 
43  const size_t offset;
44 
47  template<typename T, typename P>
48  typename std::enable_if<
49  !HasParametersCheck<T, P&(T::*)()>::value &&
50  !HasModelCheck<T>::value, size_t>::type
51  LayerSize(T* layer, P&& input) const;
52 
54  template<typename T, typename P>
55  typename std::enable_if<
56  !HasParametersCheck<T, P&(T::*)()>::value &&
57  HasModelCheck<T>::value, size_t>::type
58  LayerSize(T* layer, P&& input) const;
59 
61  template<typename T, typename P>
62  typename std::enable_if<
63  HasParametersCheck<T, P&(T::*)()>::value &&
64  !HasModelCheck<T>::value, size_t>::type
65  LayerSize(T* layer, P&& input) const;
66 
69  template<typename T, typename P>
70  typename std::enable_if<
71  HasParametersCheck<T, P&(T::*)()>::value &&
72  HasModelCheck<T>::value, size_t>::type
73  LayerSize(T* layer, P&& input) const;
74 };
75 
76 } // namespace ann
77 } // namespace mlpack
78 
79 // Include implementation.
80 #include "weight_set_visitor_impl.hpp"
81 
82 #endif
boost::variant< Recurrent< arma::mat, arma::mat > *, RecurrentAttention< arma::mat, arma::mat > *, ReinforceNormal< arma::mat, arma::mat > *, Reparametrization< arma::mat, arma::mat > *, Select< arma::mat, arma::mat > *, Sequential< arma::mat, arma::mat, false > *, Sequential< arma::mat, arma::mat, true > *, Subview< arma::mat, arma::mat > *, VRClassReward< arma::mat, arma::mat > *, VirtualBatchNorm< arma::mat, arma::mat > *> MoreTypes
strip_type.hpp
Definition: add_to_po.hpp:21
size_t operator()(LayerType *layer) const
Update the parameters set.
WeightSetVisitor update the module parameters given the parameters set.
WeightSetVisitor(arma::mat &&weight, const size_t offset=0)
Update the parameters given the parameters set and offset.