mlpack
load_output_parameter_visitor_impl.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_ANN_VISITOR_LOAD_OUTPUT_PARAMETER_VISITOR_IMPL_HPP
13 #define MLPACK_METHODS_ANN_VISITOR_LOAD_OUTPUT_PARAMETER_VISITOR_IMPL_HPP
14 
15 // In case it hasn't been included yet.
17 
18 namespace mlpack {
19 namespace ann {
20 
23  std::vector<arma::mat>& parameter) : parameter(parameter)
24 {
25  /* Nothing to do here. */
26 }
27 
28 template<typename LayerType>
29 inline void LoadOutputParameterVisitor::operator()(LayerType* layer) const
30 {
31  OutputParameter(layer);
32 }
33 
34 inline void LoadOutputParameterVisitor::operator()(MoreTypes layer) const
35 {
36  layer.apply_visitor(*this);
37 }
38 
39 template<typename T>
40 inline typename std::enable_if<
41  !HasModelCheck<T>::value, void>::type
42 LoadOutputParameterVisitor::OutputParameter(T* layer) const
43 {
44  layer->OutputParameter() = parameter.back();
45  parameter.pop_back();
46 }
47 
48 template<typename T>
49 inline typename std::enable_if<
50  HasModelCheck<T>::value, void>::type
51 LoadOutputParameterVisitor::OutputParameter(T* layer) const
52 {
53  for (size_t i = 0; i < layer->Model().size(); ++i)
54  {
55  boost::apply_visitor(LoadOutputParameterVisitor(parameter),
56  layer->Model()[layer->Model().size() - i - 1]);
57  }
58 
59  layer->OutputParameter() = parameter.back();
60  parameter.pop_back();
61 }
62 
63 } // namespace ann
64 } // namespace mlpack
65 
66 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
LoadOutputParameterVisitor(std::vector< arma::mat > &parameter)
Restore the output parameter given a parameter set.
Definition: load_output_parameter_visitor_impl.hpp:22
void operator()(LayerType *layer) const
Restore the output parameter.
Definition: load_output_parameter_visitor_impl.hpp:29