mlpack 3.4.2
Loading...
Searching...
No Matches
get_raw_param.hpp
Go to the documentation of this file.
1
13#ifndef MLPACK_BINDINGS_CLI_GET_RAW_PARAM_HPP
14#define MLPACK_BINDINGS_CLI_GET_RAW_PARAM_HPP
15
16#include <mlpack/prereqs.hpp>
17#include "parameter_type.hpp"
18
19namespace mlpack {
20namespace bindings {
21namespace cli {
22
27template<typename T>
30 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
31 const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
32 const typename boost::disable_if<std::is_same<T,
33 std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0)
34{
35 // No mapping is needed, so just cast it directly.
36 return *boost::any_cast<T>(&d.value);
37}
38
42template<typename T>
45 const typename boost::enable_if_c<
46 arma::is_arma_type<T>::value ||
47 std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
48 arma::mat>>::value>::type* = 0)
49{
50 // Don't load the matrix.
51 typedef std::tuple<T, std::string> TupleType;
52 T& value = std::get<0>(*boost::any_cast<TupleType>(&d.value));
53 return value;
54}
55
59template<typename T>
62 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
63 const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
64{
65 // Don't load the model.
66 typedef std::tuple<T*, std::string> TupleType;
67 T*& value = std::get<0>(*boost::any_cast<TupleType>(&d.value));
68 return value;
69}
70
79template<typename T>
81 const void* /* input */,
82 void* output)
83{
84 // Cast to the correct type.
85 *((T**) output) = &GetRawParam<typename std::remove_pointer<T>::type>(
86 const_cast<util::ParamData&>(d));
87}
88
89} // namespace cli
90} // namespace bindings
91} // namespace mlpack
92
93#endif
Auxiliary information for a dataset, including mappings to/from strings (or other types) and the data...
T & GetRawParam(util::ParamData &d, const typename boost::disable_if< arma::is_arma_type< T > >::type *=0, const typename boost::disable_if< data::HasSerialize< T > >::type *=0, const typename boost::disable_if< std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat > > >::type *=0)
This overload is called when nothing special needs to happen to the name of the parameter.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:53
boost::any value
The actual value that is held.
Definition: param_data.hpp:82