12 #ifndef MLPACK_CORE_CV_META_INFO_EXTRACTOR_HPP 13 #define MLPACK_CORE_CV_META_INFO_EXTRACTOR_HPP 15 #include <type_traits> 34 template<
typename MatType,
35 typename PredictionsType,
45 template<
typename PT,
typename WT,
typename T1,
typename T2>
48 using PredictionsType = PT;
49 using WeightsType = WT;
54 template<
typename Class,
typename RT,
typename... Ts>
55 using Type = RT(Class::*)(T1, T2, Ts...);
58 template<
typename PT,
typename WT,
typename T1,
typename T2,
typename T3>
61 using PredictionsType = PT;
62 using WeightsType = WT;
67 template<
typename Class,
typename RT,
typename... Ts>
68 using Type = RT(Class::*)(T1, T2, T3, Ts...);
71 template<
typename PT,
typename WT,
typename T1,
typename T2,
typename T3,
75 using PredictionsType = PT;
76 using WeightsType = WT;
81 template<
typename Class,
typename RT,
typename... Ts>
82 using Type = RT(Class::*)(T1, T2, T3, T4, Ts...);
85 template<
typename PT,
typename WT,
typename T1,
typename T2,
typename T3,
86 typename T4,
typename T5>
89 using PredictionsType = PT;
90 using WeightsType = WT;
95 template<
typename Class,
typename RT,
typename... Ts>
96 using Type = RT(Class::*)(T1, T2, T3, T4, T5, Ts...);
99 template<
typename MT,
typename PT>
101 const MT&, const PT&> {};
103 template<
typename MT,
typename PT>
105 const MT&, const data::DatasetInfo&, const PT&> {};
107 template<
typename MT,
typename PT,
typename WT>
109 const MT&, const PT&, const WT&> {};
111 template<
typename MT,
typename PT,
typename WT>
113 const MT&, const data::DatasetInfo&, const PT&, const WT&> {};
115 template<
typename MT,
typename PT>
117 const MT&, const PT&, const size_t> {};
119 template<
typename MT,
typename PT>
121 const MT&, const data::DatasetInfo&, const PT&, const size_t> {};
123 template<
typename MT,
typename PT,
typename WT>
125 const MT&, const PT&, const size_t, const WT&> {};
127 template<
typename MT,
typename PT,
typename WT>
129 const MT&, const data::DatasetInfo&, const PT&,
130 const size_t, const WT&> {};
132 template<
typename PT,
typename WT,
typename... SignatureParams>
135 using PredictionsType = PT;
136 using WeightsType = WT;
141 template<
typename Class,
typename RT,
typename... Ts>
142 using Type = RT(Class::*)(SignatureParams..., Ts...);
145 template<
typename MT,
typename PT>
146 struct TrainForm<MT, PT, void, false, false> :
public TrainFormBase<PT, void,
147 const MT&, const PT&> {};
149 template<
typename MT,
typename PT>
150 struct TrainForm<MT, PT, void, true, false> :
public TrainFormBase<PT, void,
151 const MT&, const data::DatasetInfo&, const PT&> {};
153 template<
typename MT,
typename PT,
typename WT>
154 struct TrainForm<MT, PT, WT, false, false> :
public TrainFormBase<PT, WT,
155 const MT&, const PT&, const WT&> {};
157 template<
typename MT,
typename PT,
typename WT>
158 struct TrainForm<MT, PT, WT, true, false> :
public TrainFormBase<PT, WT,
159 const MT&, const data::DatasetInfo&, const PT&, const WT&> {};
161 template<
typename MT,
typename PT>
162 struct TrainForm<MT, PT, void, false, true> :
public TrainFormBase<PT, void,
163 const MT&, const PT&, const size_t> {};
165 template<
typename MT,
typename PT>
166 struct TrainForm<MT, PT, void, true, true> :
public TrainFormBase<PT, void,
167 const MT&, const data::DatasetInfo&, const PT&, const size_t> {};
169 template<
typename MT,
typename PT,
typename WT>
170 struct TrainForm<MT, PT, WT, false, true> :
public TrainFormBase<PT, WT,
171 const MT&, const PT&, const size_t, const WT&> {};
173 template<
typename MT,
typename PT,
typename WT>
174 struct TrainForm<MT, PT, WT, true, true> :
public TrainFormBase<PT, WT,
175 const MT&, const data::DatasetInfo&, const PT&,
176 const size_t, const WT&> {};
182 using PredictionsType =
void*;
183 using WeightsType =
void*;
196 template<
typename MLAlgorithm,
197 template<
class,
template<
class...>
class,
size_t>
class... HMFs>
200 template<
typename MLAlgorithm,
201 template<
class,
template<
class...>
class,
size_t>
class HasMethodForm,
202 template<class, template<class...> class, size_t> class... HMFs>
205 template<
typename... Forms>
210 template<
typename... RemainingForms>
211 struct Implementation
214 using Type =
typename NextSMF::template From<Forms...>
::Type;
218 template<
typename Form,
typename... RemainingForms>
219 struct Implementation<Form, RemainingForms...>
221 using Type =
typename std::conditional<
222 HasMethodForm<MLAlgorithm, Form::template
Type,
223 Form::MinNumberOfAdditionalArgs>::value,
225 typename Implementation<RemainingForms...>
::Type>::type;
233 template<
typename MLAlgorithm>
236 template<
typename... Forms>
268 template<
typename MLAlgorithm,
269 typename MT = arma::mat,
270 typename PT = arma::Row<size_t>,
271 typename WT = arma::rowvec>
303 template<
typename... MethodForms>
305 HasMTrain, HasMPTrain, HasMPWTrain>::template From<MethodForms...>;
308 template<
typename... MFs >
309 using Selects =
typename std::conditional<
311 std::false_type, std::true_type>::type;
318 using PredictionsType =
319 typename Select<TF1, TF2, TF3, TF4, TF5>::Type::PredictionsType;
326 typename Select<WTF1, WTF2, WTF3, WTF4, WTF5>::Type::WeightsType;
332 static const bool IsSupported = !std::is_same<PredictionsType, void*>::value;
337 static const bool SupportsWeights = !std::is_same<WeightsType, void*>::value;
342 static const bool TakesDatasetInfo = Selects<TF5>::value;
347 static const bool TakesNumClasses = Selects<TF4, TF5>::value;
#define HAS_METHOD_FORM(METHOD, NAME)
HAS_METHOD_FORM generates a template that allows a compile time check for whether a given class has a...
Linear algebra utility functions, generally performed on matrices or vectors.
DatasetMapper< data::IncrementPolicy > DatasetInfo
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...