bias_set_visitor.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_ANN_VISITOR_BIAS_SET_VISITOR_HPP
14 #define MLPACK_METHODS_ANN_VISITOR_BIAS_SET_VISITOR_HPP
15 
17 
18 #include <boost/variant.hpp>
19 
20 namespace mlpack {
21 namespace ann {
22 
26 class BiasSetVisitor : public boost::static_visitor<size_t>
27 {
28  public:
30  BiasSetVisitor(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>
48  typename std::enable_if<
49  !HasBiasCheck<T, arma::mat&(T::*)()>::value &&
50  !HasModelCheck<T>::value, size_t>::type
51  LayerSize(T* layer) const;
52 
54  template<typename T>
55  typename std::enable_if<
56  !HasBiasCheck<T, arma::mat&(T::*)()>::value &&
57  HasModelCheck<T>::value, size_t>::type
58  LayerSize(T* layer) const;
59 
61  template<typename T>
62  typename std::enable_if<
63  HasBiasCheck<T, arma::mat&(T::*)()>::value &&
64  !HasModelCheck<T>::value, size_t>::type
65  LayerSize(T* layer) const;
66 
69  template<typename T>
70  typename std::enable_if<
71  HasBiasCheck<T, arma::mat&(T::*)()>::value &&
72  HasModelCheck<T>::value, size_t>::type
73  LayerSize(T* layer) const;
74 };
75 
76 } // namespace ann
77 } // namespace mlpack
78 
79 // Include implementation.
80 #include "bias_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&#39; set.
BiasSetVisitor updates the module bias parameters given the parameters set.
BiasSetVisitor(arma::mat &&weight, const size_t offset=0)
Update the bias parameters given the parameters&#39; set and offset.