mlpack 3.4.2
weight_size_visitor.hpp
Go to the documentation of this file.
1
14#ifndef MLPACK_METHODS_ANN_VISITOR_WEIGHT_SIZE_VISITOR_HPP
15#define MLPACK_METHODS_ANN_VISITOR_WEIGHT_SIZE_VISITOR_HPP
16
18
19#include <boost/variant.hpp>
20
21namespace mlpack {
22namespace ann {
23
27class WeightSizeVisitor : public boost::static_visitor<size_t>
28{
29 public:
31 template<typename LayerType>
32 size_t operator()(LayerType* layer) const;
33
34 size_t operator()(MoreTypes layer) const;
35
36 private:
39 template<typename T, typename P>
40 typename std::enable_if<
41 !HasParametersCheck<T, P&(T::*)()>::value &&
42 !HasModelCheck<T>::value, size_t>::type
43 LayerSize(T* layer, P& output) const;
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& output) const;
52
55 template<typename T, typename P>
56 typename std::enable_if<
57 HasParametersCheck<T, P&(T::*)()>::value &&
58 !HasModelCheck<T>::value, size_t>::type
59 LayerSize(T* layer, P& output) const;
60
63 template<typename T, typename P>
64 typename std::enable_if<
65 HasParametersCheck<T, P&(T::*)()>::value &&
66 HasModelCheck<T>::value, size_t>::type
67 LayerSize(T* layer, P& output) const;
68};
69
70} // namespace ann
71} // namespace mlpack
72
73// Include implementation.
74#include "weight_size_visitor_impl.hpp"
75
76#endif
WeightSizeVisitor returns the number of weights of the given module.
size_t operator()(MoreTypes layer) const
size_t operator()(LayerType *layer) const
Return the number of weights.
boost::variant< Linear3D< arma::mat, arma::mat, NoRegularizer > *, Glimpse< arma::mat, arma::mat > *, Highway< arma::mat, arma::mat > *, MultiheadAttention< arma::mat, arma::mat, NoRegularizer > *, 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 > *, RBF< arma::mat, arma::mat, GaussianFunction > *, BaseLayer< GaussianFunction, arma::mat, arma::mat > *, PositionalEncoding< arma::mat, arma::mat > * > MoreTypes
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1