mlpack  master
Classes | Functions | Variables
mlpack::util Namespace Reference

Classes

class  CLIDeleter
 Extremely simple class whose only job is to delete the existing CLI object at the end of execution. More...
 
struct  IsStdVector
 Metaprogramming structure for vector detection. More...
 
struct  IsStdVector< std::vector< T, A > >
 Metaprogramming structure for vector detection. More...
 
class  NullOutStream
 Used for Log::Debug when not compiled with debugging symbols. More...
 
class  Option
 A static object whose constructor registers a parameter with the CLI class. More...
 
struct  ParamData
 This structure holds all of the information about a single parameter, including its value (which is set when ParseCommandLine() is called). More...
 
struct  ParameterType
 Utility struct to return the type that boost::program_options should accept for a given input type. More...
 
struct  ParameterType< arma::Mat< eT > >
 For matrix types, boost::program_options will accept a std::string, not an arma::mat (since it is not clear how to specify a matrix on the command-line). More...
 
struct  ParameterType< std::tuple< mlpack::data::DatasetMapper< PolicyType >, arma::Mat< eT > > >
 For matrix+dataset info types, we should accept a std::string. More...
 
struct  ParameterTypeDeducer
 
struct  ParameterTypeDeducer< true, T >
 
class  PrefixedOutStream
 Allows us to output to an ostream with a prefix at the beginning of each line, in the same way we would output to cout or cerr. More...
 
class  ProgramDoc
 A static object whose constructor registers program documentation with the CLI class. More...
 

Functions

template<typename T >
std::string DefaultParam (const ParamData &data)
 Return the default value of an option. More...
 
template<typename T >
std::string DefaultParamImpl (const ParamData &data, const typename boost::disable_if< arma::is_arma_type< T >>::type *=0, const typename boost::disable_if< IsStdVector< T >>::type *=0, const typename boost::disable_if< data::HasSerialize< T >>::type *=0, const typename boost::disable_if< std::is_same< T, std::string >>::type *=0, const typename boost::disable_if< std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat >>>::type *=0)
 Return the default value of an option. More...
 
template<typename T >
std::string DefaultParamImpl (const ParamData &data, const typename boost::enable_if< IsStdVector< T >>::type *=0)
 Return the default value of a vector option. More...
 
template<typename T >
std::string DefaultParamImpl (const ParamData &data, const typename boost::enable_if_c< arma::is_arma_type< T >::value||data::HasSerialize< T >::value||std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat >>::value||std::is_same< T, std::string >::value >::type *=0)
 Return the default value of a matrix option (this returns the default filename, or '' if the default is no file). More...
 
std::string GetVersion ()
 This will return either "mlpack x.y.z" or "mlpack master-XXXXXXX" depending on whether or not this is a stable version of mlpack or a git repository. More...
 
template<typename T >
T & HandleParameter (typename util::ParameterType< T >::type &value, 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)
 If needed, map 'trueValue' to the right type and return it. More...
 
template<typename T >
T & HandleParameter (typename util::ParameterType< T >::type &value, util::ParamData &d, const typename boost::enable_if< arma::is_arma_type< T >>::type *=0)
 This must be overloaded for matrices. More...
 
template<typename T >
T & HandleParameter (typename util::ParameterType< T >::type &value, util::ParamData &d, const typename boost::enable_if< std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat >>>::type *=0)
 This must be overloaded for matrices and dataset info objects. More...
 
template<typename T >
T & HandleParameter (typename util::ParameterType< T >::type &value, util::ParamData &d, const typename boost::enable_if< data::HasSerialize< T >>::type *=0)
 This must be overloaded for serializable objects. More...
 
template<typename T >
T & HandleRawParameter (typename util::ParameterType< T >::type &value, util::ParamData &, 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< data::DatasetInfo, arma::mat >>>::type *=0)
 This will just return the value. More...
 
template<typename T >
T & HandleRawParameter (typename util::ParameterType< T >::type &, util::ParamData &d, const typename boost::enable_if< arma::is_arma_type< T >>::type *=0)
 This will return the mapped value. More...
 
template<typename T >
T & HandleRawParameter (typename util::ParameterType< T >::type &, util::ParamData &d, const typename boost::enable_if< data::HasSerialize< T >>::type *=0)
 This will return the mapped value. More...
 
template<typename T >
T & HandleRawParameter (typename util::ParameterType< T >::type &, util::ParamData &d, const typename boost::enable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *=0)
 This will return the mapped value. More...
 
template<typename T >
std::string MapParameterName (const std::string &identifier, 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)
 If needed, map the parameter name to the name that is used by boost. More...
 
template<typename T >
std::string MapParameterName (const std::string &identifier, const typename boost::enable_if_c< arma::is_arma_type< T >::value||std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat >>::value||data::HasSerialize< T >::value >::type *=0)
 This must be overloaded for matrices. More...
 
template<typename T >
void OutputParam (const ParamData &data)
 Output an option. More...
 
template<typename T >
void OutputParamImpl (const ParamData &data, const typename boost::disable_if< arma::is_arma_type< T >>::type *=0, const typename boost::disable_if< IsStdVector< T >>::type *=0, const typename boost::disable_if< data::HasSerialize< T >>::type *=0, const typename boost::disable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *=0)
 Output an option (print to stdout). More...
 
template<typename T >
void OutputParamImpl (const ParamData &data, const typename boost::enable_if< IsStdVector< T >>::type *=0)
 Output a vector option (print to stdout). More...
 
template<typename T >
void OutputParamImpl (const ParamData &data, const typename boost::enable_if< arma::is_arma_type< T >>::type *=0)
 Output a matrix option (this saves it to the given file). More...
 
template<typename T >
void OutputParamImpl (const ParamData &data, const typename boost::enable_if< data::HasSerialize< T >>::type *=0)
 Output a serializable class option (this saves it to the given file). More...
 
template<typename T >
void OutputParamImpl (const ParamData &data, const typename boost::enable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *=0)
 Output a mapped dataset. More...
 
template<typename T >
void PrintParam (const ParamData &data)
 Print an option. More...
 
template<typename T >
void PrintParamImpl (const ParamData &data, const typename boost::disable_if< arma::is_arma_type< T >>::type *=0, const typename boost::disable_if< IsStdVector< T >>::type *=0, const typename boost::disable_if< data::HasSerialize< T >>::type *=0, const typename boost::disable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *=0)
 Print an option. More...
 
template<typename T >
void PrintParamImpl (const ParamData &data, const typename boost::enable_if< IsStdVector< T >>::type *=0)
 Print a vector option, with spaces between it. More...
 
template<typename T >
void PrintParamImpl (const ParamData &data, const typename boost::enable_if< arma::is_arma_type< T >>::type *=0)
 Print a matrix option (this just prints the filename). More...
 
template<typename T >
void PrintParamImpl (const ParamData &data, const typename boost::enable_if< data::HasSerialize< T >>::type *=0)
 Print a serializable class option (this just prints the filename). More...
 
template<typename T >
void PrintParamImpl (const ParamData &data, const typename boost::enable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *=0)
 Print a mapped matrix option (this just prints the filename). More...
 
template<typename T >
std::string StringTypeParam ()
 Return a string containing the type of a parameter. More...
 
template<>
std::string StringTypeParam< bool > ()
 Return "bool". More...
 
template<>
std::string StringTypeParam< double > ()
 Return "double". More...
 
template<>
std::string StringTypeParam< float > ()
 Return "float". More...
 
template<>
std::string StringTypeParam< int > ()
 Return "int". More...
 
template<>
std::string StringTypeParam< std::string > ()
 Return "string". More...
 
template<>
std::string StringTypeParam< std::tuple< mlpack::data::DatasetInfo, arma::mat > > ()
 Return "string";. More...
 
template<typename T >
std::string StringTypeParamImpl (const typename boost::disable_if< arma::is_arma_type< T >>::type *=0, const typename boost::disable_if< IsStdVector< T >>::type *=0, const typename boost::disable_if< data::HasSerialize< T >>::type *=0)
 Return a string containing the type of the parameter. More...
 
template<typename T >
std::string StringTypeParamImpl (const typename boost::enable_if< IsStdVector< T >>::type *=0)
 Return a string containing the type of the parameter, for vector options. More...
 
template<typename T >
std::string StringTypeParamImpl (const typename boost::enable_if< arma::is_arma_type< T >>::type *=0)
 Return a string containing the type of the parameter, for matrix options. More...
 
template<typename T >
std::string StringTypeParamImpl (const typename boost::enable_if< data::HasSerialize< T >>::type *=0)
 Return a string containing the type of the parameter,. More...
 

Variables

MLPACK_EXPORT CLIDeleter cliDeleter
 

Function Documentation

template<typename T >
std::string mlpack::util::DefaultParam ( const ParamData data)

Return the default value of an option.

This is the function that will be called by the CLI module.

Definition at line 55 of file default_param.hpp.

template<typename T >
std::string mlpack::util::DefaultParamImpl ( const ParamData data,
const typename boost::disable_if< arma::is_arma_type< T >>::type *  = 0,
const typename boost::disable_if< IsStdVector< T >>::type *  = 0,
const typename boost::disable_if< data::HasSerialize< T >>::type *  = 0,
const typename boost::disable_if< std::is_same< T, std::string >>::type *  = 0,
const typename boost::disable_if< std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat >>>::type *  = 0 
)

Return the default value of an option.

template<typename T >
std::string mlpack::util::DefaultParamImpl ( const ParamData data,
const typename boost::enable_if< IsStdVector< T >>::type *  = 0 
)

Return the default value of a vector option.

template<typename T >
std::string mlpack::util::DefaultParamImpl ( const ParamData data,
const typename boost::enable_if_c< arma::is_arma_type< T >::value||data::HasSerialize< T >::value||std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat >>::value||std::is_same< T, std::string >::value >::type *  = 0 
)

Return the default value of a matrix option (this returns the default filename, or '' if the default is no file).

std::string mlpack::util::GetVersion ( )

This will return either "mlpack x.y.z" or "mlpack master-XXXXXXX" depending on whether or not this is a stable version of mlpack or a git repository.

template<typename T >
T& mlpack::util::HandleParameter ( typename util::ParameterType< T >::type &  value,
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 
)

If needed, map 'trueValue' to the right type and return it.

This is called from GetParam().

template<typename T >
T& mlpack::util::HandleParameter ( typename util::ParameterType< T >::type &  value,
util::ParamData d,
const typename boost::enable_if< arma::is_arma_type< T >>::type *  = 0 
)

This must be overloaded for matrices.

template<typename T >
T& mlpack::util::HandleParameter ( typename util::ParameterType< T >::type &  value,
util::ParamData d,
const typename boost::enable_if< std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat >>>::type *  = 0 
)

This must be overloaded for matrices and dataset info objects.

template<typename T >
T& mlpack::util::HandleParameter ( typename util::ParameterType< T >::type &  value,
util::ParamData d,
const typename boost::enable_if< data::HasSerialize< T >>::type *  = 0 
)

This must be overloaded for serializable objects.

template<typename T >
T& mlpack::util::HandleRawParameter ( typename util::ParameterType< T >::type &  value,
util::ParamData ,
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< data::DatasetInfo, arma::mat >>>::type *  = 0 
)

This will just return the value.

Definition at line 199 of file param_data.hpp.

References mlpack::util::IsStdVector< T >::value.

template<typename T >
T& mlpack::util::HandleRawParameter ( typename util::ParameterType< T >::type &  ,
util::ParamData d,
const typename boost::enable_if< arma::is_arma_type< T >>::type *  = 0 
)

This will return the mapped value.

Definition at line 212 of file param_data.hpp.

References mlpack::util::ParamData::mappedValue.

template<typename T >
T& mlpack::util::HandleRawParameter ( typename util::ParameterType< T >::type &  ,
util::ParamData d,
const typename boost::enable_if< data::HasSerialize< T >>::type *  = 0 
)

This will return the mapped value.

Definition at line 222 of file param_data.hpp.

References mlpack::util::ParamData::mappedValue.

template<typename T >
T& mlpack::util::HandleRawParameter ( typename util::ParameterType< T >::type &  ,
util::ParamData d,
const typename boost::enable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *  = 0 
)

This will return the mapped value.

Definition at line 232 of file param_data.hpp.

References mlpack::util::ParamData::mappedValue.

template<typename T >
std::string mlpack::util::MapParameterName ( const std::string identifier,
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 
)

If needed, map the parameter name to the name that is used by boost.

This is generally the same as the name, but for matrices it may be different.

template<typename T >
std::string mlpack::util::MapParameterName ( const std::string identifier,
const typename boost::enable_if_c< arma::is_arma_type< T >::value||std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat >>::value||data::HasSerialize< T >::value >::type *  = 0 
)

This must be overloaded for matrices.

template<typename T >
void mlpack::util::OutputParam ( const ParamData data)

Output an option.

This is the function that will be called by the CLI module.

Definition at line 66 of file output_param.hpp.

template<typename T >
void mlpack::util::OutputParamImpl ( const ParamData data,
const typename boost::disable_if< arma::is_arma_type< T >>::type *  = 0,
const typename boost::disable_if< IsStdVector< T >>::type *  = 0,
const typename boost::disable_if< data::HasSerialize< T >>::type *  = 0,
const typename boost::disable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *  = 0 
)

Output an option (print to stdout).

template<typename T >
void mlpack::util::OutputParamImpl ( const ParamData data,
const typename boost::enable_if< IsStdVector< T >>::type *  = 0 
)

Output a vector option (print to stdout).

template<typename T >
void mlpack::util::OutputParamImpl ( const ParamData data,
const typename boost::enable_if< arma::is_arma_type< T >>::type *  = 0 
)

Output a matrix option (this saves it to the given file).

template<typename T >
void mlpack::util::OutputParamImpl ( const ParamData data,
const typename boost::enable_if< data::HasSerialize< T >>::type *  = 0 
)

Output a serializable class option (this saves it to the given file).

template<typename T >
void mlpack::util::OutputParamImpl ( const ParamData data,
const typename boost::enable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *  = 0 
)

Output a mapped dataset.

template<typename T >
void mlpack::util::PrintParam ( const ParamData data)

Print an option.

Definition at line 66 of file print_param.hpp.

template<typename T >
void mlpack::util::PrintParamImpl ( const ParamData data,
const typename boost::disable_if< arma::is_arma_type< T >>::type *  = 0,
const typename boost::disable_if< IsStdVector< T >>::type *  = 0,
const typename boost::disable_if< data::HasSerialize< T >>::type *  = 0,
const typename boost::disable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *  = 0 
)

Print an option.

template<typename T >
void mlpack::util::PrintParamImpl ( const ParamData data,
const typename boost::enable_if< IsStdVector< T >>::type *  = 0 
)

Print a vector option, with spaces between it.

template<typename T >
void mlpack::util::PrintParamImpl ( const ParamData data,
const typename boost::enable_if< arma::is_arma_type< T >>::type *  = 0 
)

Print a matrix option (this just prints the filename).

template<typename T >
void mlpack::util::PrintParamImpl ( const ParamData data,
const typename boost::enable_if< data::HasSerialize< T >>::type *  = 0 
)

Print a serializable class option (this just prints the filename).

template<typename T >
void mlpack::util::PrintParamImpl ( const ParamData data,
const typename boost::enable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *  = 0 
)

Print a mapped matrix option (this just prints the filename).

template<typename T >
std::string mlpack::util::StringTypeParam ( )

Return a string containing the type of a parameter.

This overload is used if we don't have a primitive type.

Definition at line 51 of file string_type_param.hpp.

References string(), StringTypeParam< bool >(), StringTypeParam< double >(), StringTypeParam< float >(), and StringTypeParam< int >().

template<>
std::string mlpack::util::StringTypeParam< bool > ( )
inline

Return "bool".

Referenced by StringTypeParam().

template<>
std::string mlpack::util::StringTypeParam< double > ( )
inline

Return "double".

Referenced by StringTypeParam().

template<>
std::string mlpack::util::StringTypeParam< float > ( )
inline

Return "float".

Referenced by StringTypeParam().

template<>
std::string mlpack::util::StringTypeParam< int > ( )
inline

Return "int".

Referenced by StringTypeParam().

Return "string".

template<>
std::string mlpack::util::StringTypeParam< std::tuple< mlpack::data::DatasetInfo, arma::mat > > ( )
inline

Return "string";.

template<typename T >
std::string mlpack::util::StringTypeParamImpl ( const typename boost::disable_if< arma::is_arma_type< T >>::type *  = 0,
const typename boost::disable_if< IsStdVector< T >>::type *  = 0,
const typename boost::disable_if< data::HasSerialize< T >>::type *  = 0 
)

Return a string containing the type of the parameter.

template<typename T >
std::string mlpack::util::StringTypeParamImpl ( const typename boost::enable_if< IsStdVector< T >>::type *  = 0)

Return a string containing the type of the parameter, for vector options.

template<typename T >
std::string mlpack::util::StringTypeParamImpl ( const typename boost::enable_if< arma::is_arma_type< T >>::type *  = 0)

Return a string containing the type of the parameter, for matrix options.

template<typename T >
std::string mlpack::util::StringTypeParamImpl ( const typename boost::enable_if< data::HasSerialize< T >>::type *  = 0)

Return a string containing the type of the parameter,.

Variable Documentation

MLPACK_EXPORT CLIDeleter mlpack::util::cliDeleter