add duplicate option check and drop unused functions
This commit is contained in:
@@ -6,3 +6,6 @@ build*
|
||||
*.bak
|
||||
src/mlpack/core/util/gitversion.hpp
|
||||
src/mlpack/core/util/arma_config.hpp
|
||||
|
||||
.idea
|
||||
|
||||
|
||||
@@ -6,16 +6,12 @@
|
||||
*/
|
||||
#include <list>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/any.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "cli.hpp"
|
||||
#include "log.hpp"
|
||||
|
||||
#include "option.hpp"
|
||||
|
||||
using namespace mlpack;
|
||||
using namespace mlpack::util;
|
||||
|
||||
@@ -108,7 +104,8 @@ void CLI::Add(const std::string& identifier,
|
||||
po::options_description& desc = CLI::GetSingleton().desc;
|
||||
|
||||
// Must make use of boost option name syntax.
|
||||
std::string progOptId = alias.length() ? identifier + "," + alias : identifier;
|
||||
std::string progOptId =
|
||||
alias.length() ? identifier + "," + alias : identifier;
|
||||
|
||||
// Deal with a required alias.
|
||||
AddAlias(alias, identifier);
|
||||
@@ -453,36 +450,6 @@ void CLI::RemoveDuplicateFlags(po::basic_parsed_options<char>& bpo)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a stream for arguments
|
||||
*
|
||||
* @param stream The stream to be parsed.
|
||||
*/
|
||||
void CLI::ParseStream(std::istream& stream)
|
||||
{
|
||||
po::variables_map& vmap = GetSingleton().vmap;
|
||||
po::options_description& desc = GetSingleton().desc;
|
||||
|
||||
// Parse the stream; place options & values into vmap.
|
||||
try
|
||||
{
|
||||
po::store(po::parse_config_file(stream, desc), vmap);
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
Log::Fatal << ex.what() << std::endl;
|
||||
}
|
||||
|
||||
// Flush the buffer; make sure changes are propagated to vmap.
|
||||
po::notify(vmap);
|
||||
|
||||
UpdateGmap();
|
||||
DefaultMessages();
|
||||
RequiredOptions();
|
||||
|
||||
Timer::Start("total_time");
|
||||
}
|
||||
|
||||
/* Prints out the current hierarchy. */
|
||||
void CLI::Print()
|
||||
{
|
||||
|
||||
@@ -635,13 +635,6 @@ class CLI
|
||||
*/
|
||||
static void RemoveDuplicateFlags(po::basic_parsed_options<char>& bpo);
|
||||
|
||||
/**
|
||||
* Parses a stream for arguments.
|
||||
*
|
||||
* @param stream The stream to be parsed.
|
||||
*/
|
||||
static void ParseStream(std::istream& stream);
|
||||
|
||||
/**
|
||||
* Print out the current hierarchy.
|
||||
*/
|
||||
@@ -673,7 +666,7 @@ class CLI
|
||||
//! Values of the options given by user.
|
||||
po::variables_map vmap;
|
||||
|
||||
//! Pathnames of required options.
|
||||
//! Identifier names of required options.
|
||||
std::list<std::string> requiredOptions;
|
||||
|
||||
//! Map of global values.
|
||||
@@ -728,15 +721,6 @@ class CLI
|
||||
*/
|
||||
static void RequiredOptions();
|
||||
|
||||
/**
|
||||
* Cleans up input pathnames, rendering strings such as /foo/bar
|
||||
* and foo/bar/ equivalent inputs.
|
||||
*
|
||||
* @param str Input string.
|
||||
* @return Sanitized string.
|
||||
*/
|
||||
static std::string SanitizeString(const std::string& str);
|
||||
|
||||
/**
|
||||
* Parses the values given on the command line, overriding any default values.
|
||||
*/
|
||||
|
||||
@@ -9,10 +9,20 @@
|
||||
|
||||
// In case it has not already been included.
|
||||
#include "cli.hpp"
|
||||
#include "prefixedoutstream.hpp"
|
||||
|
||||
// Include option.hpp here because it requires CLI but is also templated.
|
||||
#include "option.hpp"
|
||||
|
||||
// Color code escape sequences.
|
||||
#ifndef _WIN32
|
||||
#define BASH_RED "\033[0;31m"
|
||||
#define BASH_CLEAR "\033[0m"
|
||||
#else
|
||||
#define BASH_RED ""
|
||||
#define BASH_CLEAR ""
|
||||
#endif
|
||||
|
||||
namespace mlpack {
|
||||
|
||||
/**
|
||||
@@ -33,10 +43,21 @@ void CLI::Add(const std::string& identifier,
|
||||
const std::string& alias,
|
||||
bool required)
|
||||
{
|
||||
util::PrefixedOutStream outstr(std::cerr,
|
||||
BASH_RED "[FATAL] " BASH_CLEAR, false, true /* fatal */);
|
||||
gmap_t& gmap = GetSingleton().globalValues;
|
||||
amap_t& amap = GetSingleton().aliasValues;
|
||||
if (gmap.count(identifier))
|
||||
outstr << "Parameter --" << identifier << "(-" << alias << ") "
|
||||
<< "is defined multiple times with same identifiers." << std::endl;
|
||||
if (amap.count(alias))
|
||||
outstr << "Parameter --" << identifier << "(-" << alias << ") "
|
||||
<< "is defined multiple times with same alias." << std::endl;
|
||||
|
||||
po::options_description& desc = CLI::GetSingleton().desc;
|
||||
// Must make use of boost syntax here.
|
||||
std::string progOptId = alias.length() ? identifier + "," + alias : identifier;
|
||||
std::string progOptId =
|
||||
alias.length() ? identifier + "," + alias : identifier;
|
||||
|
||||
// Add the alias, if necessary
|
||||
AddAlias(alias, identifier);
|
||||
@@ -45,8 +66,6 @@ void CLI::Add(const std::string& identifier,
|
||||
desc.add_options()(progOptId.c_str(), po::value<T>(), description.c_str());
|
||||
|
||||
// Make sure the appropriate metadata is inserted into gmap.
|
||||
gmap_t& gmap = GetSingleton().globalValues;
|
||||
|
||||
ParamData data;
|
||||
T tmp = T();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace ann /** Artificial Neural Network. */ {
|
||||
* Implementation of a standard feed forward network.
|
||||
*
|
||||
* @tparam LayerTypes Contains all layer modules used to construct the network.
|
||||
* @tparam OutputLayerType The outputlayer type used to evaluate the network.
|
||||
* @tparam OutputLayerType The output layer type used to evaluate the network.
|
||||
* @tparam InitializationRuleType Rule used to initialize the weight matrix.
|
||||
* @tparam PerformanceFunction Performance strategy used to calculate the error.
|
||||
*/
|
||||
@@ -48,14 +48,14 @@ class FFN
|
||||
* be used.
|
||||
*
|
||||
* @param network Network modules used to construct the network.
|
||||
* @param outputLayer Outputlayer used to evaluate the network.
|
||||
* @param outputLayer Output layer used to evaluate the network.
|
||||
* @param predictors Input training variables.
|
||||
* @param responses Outputs resulting from input training variables.
|
||||
* @param optimizer Instantiated optimizer used to train the model.
|
||||
* @param initializeRule Optional instantiated InitializationRule object
|
||||
* for initializing the network paramter.
|
||||
* for initializing the network parameter.
|
||||
* @param performanceFunction Optional instantiated PerformanceFunction
|
||||
* object used to claculate the error.
|
||||
* object used to calculate the error.
|
||||
*/
|
||||
template<typename LayerType,
|
||||
typename OutputType,
|
||||
@@ -74,13 +74,13 @@ class FFN
|
||||
* initialize rule and performance function should be used.
|
||||
*
|
||||
* @param network Network modules used to construct the network.
|
||||
* @param outputLayer Outputlayer used to evaluate the network.
|
||||
* @param outputLayer Output layer used to evaluate the network.
|
||||
* @param predictors Input training variables.
|
||||
* @param responses Outputs resulting from input training variables.
|
||||
* @param initializeRule Optional instantiated InitializationRule object
|
||||
* for initializing the network paramter.
|
||||
* for initializing the network parameter.
|
||||
* @param performanceFunction Optional instantiated PerformanceFunction
|
||||
* object used to claculate the error.
|
||||
* object used to calculate the error.
|
||||
*/
|
||||
template<typename LayerType, typename OutputType>
|
||||
FFN(LayerType &&network,
|
||||
@@ -96,11 +96,11 @@ class FFN
|
||||
* training.
|
||||
*
|
||||
* @param network Network modules used to construct the network.
|
||||
* @param outputLayer Outputlayer used to evaluate the network.
|
||||
* @param outputLayer Output layer used to evaluate the network.
|
||||
* @param initializeRule Optional instantiated InitializationRule object
|
||||
* for initializing the network paramter.
|
||||
* for initializing the network parameter.
|
||||
* @param performanceFunction Optional instantiated PerformanceFunction
|
||||
* object used to claculate the error.
|
||||
* object used to calculate the error.
|
||||
*/
|
||||
template<typename LayerType, typename OutputType>
|
||||
FFN(LayerType &&network,
|
||||
@@ -408,10 +408,10 @@ private:
|
||||
//! Instantiated feedforward network.
|
||||
LayerTypes network;
|
||||
|
||||
//! The outputlayer used to evaluate the network
|
||||
//! The output layer used to evaluate the network
|
||||
OutputLayerType outputLayer;
|
||||
|
||||
//! Performance strategy used to claculate the error.
|
||||
//! Performance strategy used to calculate the error.
|
||||
PerformanceFunction performanceFunc;
|
||||
|
||||
//! The current evaluation mode (training or testing).
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace ann /** Artificial Neural Network. */ {
|
||||
* Implementation of a standard recurrent neural network.
|
||||
*
|
||||
* @tparam LayerTypes Contains all layer modules used to construct the network.
|
||||
* @tparam OutputLayerType The outputlayer type used to evaluate the network.
|
||||
* @tparam OutputLayerType The output layer type used to evaluate the network.
|
||||
* @tparam InitializationRuleType Rule used to initialize the weight matrix.
|
||||
* @tparam PerformanceFunction Performance strategy used to calculate the error.
|
||||
*/
|
||||
@@ -50,14 +50,14 @@ class RNN
|
||||
* be used.
|
||||
*
|
||||
* @param network Network modules used to construct the network.
|
||||
* @param outputLayer Outputlayer used to evaluate the network.
|
||||
* @param outputLayer Output layer used to evaluate the network.
|
||||
* @param predictors Input training variables.
|
||||
* @param responses Outputs resulting from input training variables.
|
||||
* @param optimizer Instantiated optimizer used to train the model.
|
||||
* @param initializeRule Optional instantiated InitializationRule object
|
||||
* for initializing the network paramter.
|
||||
* for initializing the network parameter.
|
||||
* @param performanceFunction Optional instantiated PerformanceFunction
|
||||
* object used to claculate the error.
|
||||
* object used to calculate the error.
|
||||
*/
|
||||
template<typename LayerType,
|
||||
typename OutputType,
|
||||
@@ -76,13 +76,13 @@ class RNN
|
||||
* initialize rule and performance function should be used.
|
||||
*
|
||||
* @param network Network modules used to construct the network.
|
||||
* @param outputLayer Outputlayer used to evaluate the network.
|
||||
* @param outputLayer Output layer used to evaluate the network.
|
||||
* @param predictors Input training variables.
|
||||
* @param responses Outputs resulting from input training variables.
|
||||
* @param initializeRule Optional instantiated InitializationRule object
|
||||
* for initializing the network paramter.
|
||||
* for initializing the network parameter.
|
||||
* @param performanceFunction Optional instantiated PerformanceFunction
|
||||
* object used to claculate the error.
|
||||
* object used to calculate the error.
|
||||
*/
|
||||
template<typename LayerType, typename OutputType>
|
||||
RNN(LayerType &&network,
|
||||
@@ -98,11 +98,11 @@ class RNN
|
||||
* training.
|
||||
*
|
||||
* @param network Network modules used to construct the network.
|
||||
* @param outputLayer Outputlayer used to evaluate the network.
|
||||
* @param outputLayer Output layer used to evaluate the network.
|
||||
* @param initializeRule Optional instantiated InitializationRule object
|
||||
* for initializing the network paramter.
|
||||
* for initializing the network parameter.
|
||||
* @param performanceFunction Optional instantiated PerformanceFunction
|
||||
* object used to claculate the error.
|
||||
* object used to calculate the error.
|
||||
*/
|
||||
template<typename LayerType, typename OutputType>
|
||||
RNN(LayerType &&network,
|
||||
|
||||
Reference in New Issue
Block a user