[mlpack] 21/35: Add reverse compatibility for some incorrectly-named parameters.
Barak A. Pearlmutter
barak+git at pearlmutter.net
Thu Sep 15 23:29:41 UTC 2016
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to branch master
in repository mlpack.
commit 2a3e19bca00858108e16bae94b3417153934d676
Author: Ryan Curtin <ryan at ratml.org>
Date: Fri Jul 15 11:41:07 2016 -0400
Add reverse compatibility for some incorrectly-named parameters.
In addition, the behavior and checks for some input parameters has been slightly
changed in places, sometimes fixing bugs.
---
src/mlpack/core/util/cli.cpp | 5 ++
src/mlpack/methods/lars/lars_main.cpp | 26 ++++---
.../linear_regression/linear_regression_main.cpp | 43 +++++++++--
src/mlpack/methods/mean_shift/mean_shift_main.cpp | 70 +++++++++++++-----
src/mlpack/methods/nca/nca_main.cpp | 7 +-
src/mlpack/methods/pca/pca_main.cpp | 3 -
.../preprocess/preprocess_binarize_main.cpp | 85 ++++++++++++++++++++++
.../methods/preprocess/preprocess_split_main.cpp | 47 +++++++-----
src/mlpack/methods/radical/radical_main.cpp | 53 ++++++++++++--
.../softmax_regression/softmax_regression_main.cpp | 3 +-
10 files changed, 279 insertions(+), 63 deletions(-)
diff --git a/src/mlpack/core/util/cli.cpp b/src/mlpack/core/util/cli.cpp
index ae3c06e..8f46537 100644
--- a/src/mlpack/core/util/cli.cpp
+++ b/src/mlpack/core/util/cli.cpp
@@ -600,6 +600,11 @@ void CLI::PrintHelp(const std::string& param)
if ((pass == 1) && required)
continue; // Don't print this one.
+ // For reverse compatibility: this can be removed when these options are
+ // gone in mlpack 3.0.0. We don't want to print the deprecated options.
+ if (data.name == "inputFile")
+ continue;
+
if (!printedHeader)
{
printedHeader = true;
diff --git a/src/mlpack/methods/lars/lars_main.cpp b/src/mlpack/methods/lars/lars_main.cpp
index 5c5632c..ba7ead1 100644
--- a/src/mlpack/methods/lars/lars_main.cpp
+++ b/src/mlpack/methods/lars/lars_main.cpp
@@ -61,10 +61,10 @@ PARAM_STRING("test_file", "File containing points to regress on (test "
// Kept for reverse compatibility until mlpack 3.0.0.
PARAM_STRING("output_predictions", "If --test_file is specified, this file "
- "is where the predicted responses will be saved.", "");
+ "is where the predicted responses will be saved.", "", "");
// This is the future name of the parameter.
PARAM_STRING("output_predictions_file", "If --test_file is specified, this "
- "file is where the predicted responses will be saved.", "o");
+ "file is where the predicted responses will be saved.", "o", "");
PARAM_DOUBLE("lambda1", "Regularization parameter for l1-norm penalty.", "l",
0);
@@ -101,7 +101,9 @@ int main(int argc, char* argv[])
CLI::GetParam<string>("output_predictions");
}
- // Check parameters -- make sure everything given makes sense.
+ // Check parameters -- make sure everything given makes sense. These checks
+ // can be simplified to HasParam() after the reverse compatibility options are
+ // removed.
if (CLI::HasParam("input_file") && !CLI::HasParam("responses_file"))
Log::Fatal << "--input_file (-i) is specified, but --responses_file (-r) is"
<< " not!" << endl;
@@ -119,17 +121,19 @@ int main(int argc, char* argv[])
Log::Fatal << "Both --input_file (-i) and --input_model_file (-m) are "
<< "specified, but only one may be specified!" << endl;
- if (!CLI::HasParam("output_predictions") &&
+ if ((CLI::GetParam<string>("output_predictions_file") == "") &&
!CLI::HasParam("output_model_file"))
- Log::Warn << "--output_predictions (-o) and --output_model_file (-M) "
+ Log::Warn << "--output_predictions_file (-o) and --output_model_file (-M) "
<< "are not specified; no results will be saved!" << endl;
- if (CLI::HasParam("output_predictions") && !CLI::HasParam("test_file"))
- Log::Warn << "--output_predictions (-o) specified, but --test_file "
+ if ((CLI::GetParam<string>("output_predictions_file") == "") &&
+ !CLI::HasParam("test_file"))
+ Log::Warn << "--output_predictions_file (-o) specified, but --test_file "
<< "(-t) is not; no results will be saved." << endl;
- if (CLI::HasParam("test_file") && !CLI::HasParam("output_predictions"))
- Log::Warn << "--test_file (-t) specified, but --output_predictions "
+ if (CLI::HasParam("test_file") &&
+ (CLI::GetParam<string>("output_predictions_file") == ""))
+ Log::Warn << "--test_file (-t) specified, but --output_predictions_file "
<< "(-o) is not; no results will be saved." << endl;
// Initialize the object.
@@ -189,10 +193,10 @@ int main(int argc, char* argv[])
lars.Predict(testPoints.t(), predictions, false);
// Save test predictions. One per line, so, don't transpose on save.
- if (CLI::HasParam("output_predictions"))
+ if (CLI::GetParam<string>("output_predictions_file") != "")
{
const string outputPredictionsFile =
- CLI::GetParam<string>("output_predictions");
+ CLI::GetParam<string>("output_predictions_file");
data::Save(outputPredictionsFile, predictions, true, false);
}
}
diff --git a/src/mlpack/methods/linear_regression/linear_regression_main.cpp b/src/mlpack/methods/linear_regression/linear_regression_main.cpp
index 0e8ae79..f7b9892 100644
--- a/src/mlpack/methods/linear_regression/linear_regression_main.cpp
+++ b/src/mlpack/methods/linear_regression/linear_regression_main.cpp
@@ -44,8 +44,13 @@ PARAM_STRING("input_model_file", "File containing existing model (parameters).",
PARAM_STRING("output_model_file", "File to save trained model to.", "M", "");
PARAM_STRING("test_file", "File containing X' (test regressors).", "T", "");
-PARAM_STRING("output_predictions", "If --test_file is specified, this "
- "file is where the predicted responses will be saved.", "p", "");
+
+// Keep for reverse compatibility. We can remove these for mlpack 3.0.0.
+PARAM_STRING("output_predictions", "If --test_file is specified, this file "
+ "is where the predicted responses will be saved.", "p", "");
+// This is the future name of the parameter.
+PARAM_STRING("output_predictions_file", "If --test_file is specified, this "
+ "file is where the predicted responses will be saved.", "o", "");
PARAM_DOUBLE("lambda", "Tikhonov regularization for ridge regression. If 0, "
"the method reduces to linear regression.", "l", 0.0);
@@ -60,16 +65,35 @@ int main(int argc, char* argv[])
// Handle parameters.
CLI::ParseCommandLine(argc, argv);
+ // Reverse compatibility. We can remove these for mlpack 3.0.0.
+ if (CLI::HasParam("output_predictions") &&
+ CLI::HasParam("output_predictions_file"))
+ Log::Fatal << "Cannot specify both --output_predictions and "
+ << "--output_predictions_file!" << endl;
+
+ if (CLI::HasParam("output_predictions"))
+ {
+ Log::Warn << "--output_predictions (-p) is deprecated and will be removed "
+ << "in mlpack 3.0.0; use --output_predictions_file (-o) instead."
+ << endl;
+ CLI::GetParam<string>("output_predictions_file") =
+ CLI::GetParam<string>("output_predictions");
+ }
+
const string inputModelFile = CLI::GetParam<string>("input_model_file");
const string outputModelFile = CLI::GetParam<string>("output_model_file");
const string outputPredictionsFile =
- CLI::GetParam<string>("output_predictions");
+ CLI::GetParam<string>("output_predictions_file");
const string trainingResponsesFile =
CLI::GetParam<string>("training_responses");
const string testFile = CLI::GetParam<string>("test_file");
const string trainFile = CLI::GetParam<string>("training_file");
const double lambda = CLI::GetParam<double>("lambda");
+ if (testFile == "" && outputPredictionsFile != "")
+ Log::Warn << "--output_predictions_file (-o) ignored because --test_file "
+ << "(-T) is not specified." << endl;
+
mat regressors;
mat responses;
@@ -99,8 +123,9 @@ int main(int argc, char* argv[])
<< "both." << endl;
}
- if (CLI::HasParam("test_file") && !CLI::HasParam("output_predictions"))
- Log::Warn << "--test_file (-t) specified, but --output_predictions "
+ if (CLI::HasParam("test_file") &&
+ (CLI::GetParam<string>("output_predictions_file") == ""))
+ Log::Warn << "--test_file (-t) specified, but --output_predictions_file "
<< "(-o) is not; no results will be saved." << endl;
// If they specified a model file, we also need a test file or we
@@ -116,6 +141,12 @@ int main(int argc, char* argv[])
Log::Warn << "--lambda ignored because no model is being trained." << endl;
}
+ if (outputModelFile == "" && outputPredictionsFile == "")
+ {
+ Log::Warn << "Neither --output_model_file nor --output_predictions_file are "
+ << "specified; no output will be saved!" << endl;
+ }
+
// An input file was given and we need to generate the model.
if (computeModel)
{
@@ -189,7 +220,7 @@ int main(int argc, char* argv[])
Timer::Stop("prediction");
// Save predictions.
- if (CLI::HasParam("output_predictions"))
+ if (outputPredictionsFile != "")
data::Save(outputPredictionsFile, predictions, true, false);
}
}
diff --git a/src/mlpack/methods/mean_shift/mean_shift_main.cpp b/src/mlpack/methods/mean_shift/mean_shift_main.cpp
index f417d66..d1e2979 100644
--- a/src/mlpack/methods/mean_shift/mean_shift_main.cpp
+++ b/src/mlpack/methods/mean_shift/mean_shift_main.cpp
@@ -28,16 +28,22 @@ PROGRAM_INFO("Mean Shift Clustering", "This program performs mean shift "
"in a separate file.");
// Required options.
-PARAM_STRING_REQ("inputFile", "Input dataset to perform clustering on.", "i");
+PARAM_STRING("input_file", "Input dataset to perform clustering on.",
+ "i", "");
+// This is kept for reverse compatibility and may be removed in mlpack 3.0.0.
+// At that time, --input_file should be made a required parameter.
+PARAM_STRING("inputFile", "Input dataset to perform clustering on.", "", "");
// Output options.
PARAM_FLAG("in_place", "If specified, a column containing the learned cluster "
- "assignments will be added to the input dataset file. In this case,"
- " --outputFile is overridden.", "P");
-PARAM_STRING("output_file", "File to write output labels or labeled data to.",
- "o", "");
-PARAM_STRING("centroid_file", "If specified, the centroids of each cluster will"
- " be written to the given file.", "C", "");
+ "assignments will be added to the input dataset file. In this case, "
+ "--output_file is overridden.", "P");
+PARAM_FLAG("labels_only", "If specified, only the output labels will be "
+ "written to the file specified by --output_file.", "l");
+PARAM_STRING("output_file", "File to write output labels or labeled data "
+ "to.", "o", "");
+PARAM_STRING("centroid_file", "If specified, the centroids of each cluster "
+ "will be written to the given file.", "C", "");
// Mean shift configuration options.
PARAM_INT("max_iterations", "Maximum number of iterations before mean shift "
@@ -51,7 +57,21 @@ int main(int argc, char** argv)
{
CLI::ParseCommandLine(argc, argv);
- const string inputFile = CLI::GetParam<string>("inputFile");
+ // This is for reverse compatibility and may be removed in mlpack 3.0.0.
+ if (CLI::HasParam("inputFile") && CLI::HasParam("input_file"))
+ Log::Fatal << "Cannot specify both --input_file and --inputFile!" << endl;
+
+ if (CLI::HasParam("inputFile"))
+ {
+ Log::Warn << "--inputFile is deprecated and will be removed in mlpack "
+ << "3.0.0; use --input_file instead." << endl;
+ CLI::GetParam<string>("input_file") = CLI::GetParam<string>("inputFile");
+ }
+
+ if (CLI::GetParam<string>("input_file") == "")
+ Log::Fatal << "--input_file must be specified!" << endl;
+
+ const string inputFile = CLI::GetParam<string>("input_file");
const double radius = CLI::GetParam<double>("radius");
const int maxIterations = CLI::GetParam<int>("max_iterations");
@@ -69,6 +89,10 @@ int main(int argc, char** argv)
<< "no results will be saved." << endl;
}
+ if (CLI::HasParam("labels_only") && !CLI::HasParam("output_file"))
+ Log::Warn << "--labels_only ignored because --output_file is not specified."
+ << endl;
+
arma::mat dataset;
data::Load(inputFile, dataset, true); // Fatal upon failure.
arma::mat centroids;
@@ -100,16 +124,26 @@ int main(int argc, char** argv)
}
else
{
- // Convert the assignments to doubles.
- arma::vec converted(assignments.n_elem);
- for (size_t i = 0; i < assignments.n_elem; i++)
- converted(i) = (double) assignments(i);
-
- dataset.insert_rows(dataset.n_rows, trans(converted));
-
- // Now save, in the different file.
- string outputFile = CLI::GetParam<string>("output_file");
- data::Save(outputFile, dataset);
+ if (!CLI::HasParam("labels_only"))
+ {
+ // Convert the assignments to doubles.
+ arma::vec converted(assignments.n_elem);
+ for (size_t i = 0; i < assignments.n_elem; i++)
+ converted(i) = (double) assignments(i);
+
+ dataset.insert_rows(dataset.n_rows, trans(converted));
+
+ // Now save, in the different file.
+ string outputFile = CLI::GetParam<string>("output_file");
+ if (outputFile != "")
+ data::Save(outputFile, dataset);
+ }
+ else
+ {
+ string outputFile = CLI::GetParam<string>("output_file");
+ if (outputFile != "")
+ data::Save(outputFile, assignments, false, false); // No transpose.
+ }
}
// Should we write the centroids to a file?
diff --git a/src/mlpack/methods/nca/nca_main.cpp b/src/mlpack/methods/nca/nca_main.cpp
index ad77f07..ad957ad 100644
--- a/src/mlpack/methods/nca/nca_main.cpp
+++ b/src/mlpack/methods/nca/nca_main.cpp
@@ -130,6 +130,10 @@ int main(int argc, char* argv[])
const string labelsFile = CLI::GetParam<string>("labels_file");
const string outputFile = CLI::GetParam<string>("output_file");
+ if (outputFile == "")
+ Log::Warn << "--output_file (-o) not specified; no output will be saved!"
+ << endl;
+
const string optimizerType = CLI::GetParam<string>("optimizer");
if ((optimizerType != "sgd") && (optimizerType != "lbfgs") &&
@@ -285,5 +289,6 @@ int main(int argc, char* argv[])
}
// Save the output.
- data::Save(CLI::GetParam<string>("output_file"), distance, true);
+ if (outputFile != "")
+ data::Save(outputFile, distance, true);
}
diff --git a/src/mlpack/methods/pca/pca_main.cpp b/src/mlpack/methods/pca/pca_main.cpp
index d9e5c64..be94df2 100644
--- a/src/mlpack/methods/pca/pca_main.cpp
+++ b/src/mlpack/methods/pca/pca_main.cpp
@@ -38,9 +38,6 @@ PARAM_DOUBLE("var_to_retain", "Amount of variance to retain; should be between "
PARAM_FLAG("scale", "If set, the data will be scaled before running PCA, such "
"that the variance of each feature is 1.", "s");
-PARAM_STRING_IN("decomposition_method", "Method used for the principal"
- "components analysis: 'exact', 'randomized', 'quic'.", "c", "exact");
-
int main(int argc, char** argv)
{
// Parse commandline.
diff --git a/src/mlpack/methods/preprocess/preprocess_binarize_main.cpp b/src/mlpack/methods/preprocess/preprocess_binarize_main.cpp
new file mode 100644
index 0000000..efad2bf
--- /dev/null
+++ b/src/mlpack/methods/preprocess/preprocess_binarize_main.cpp
@@ -0,0 +1,85 @@
+/**
+ * @file preprocess_binarize_main.cpp
+ * @author Keon Kim
+ *
+ * binarize CLI executable
+ */
+#include <mlpack/core.hpp>
+#include <mlpack/core/data/binarize.hpp>
+
+PROGRAM_INFO("Binarize Data", "This utility takes a dataset and binarizes the "
+ "variables into either 0 or 1 given threshold. User can apply binarization "
+ "on a dimension or the whole dataset. A dimension can be specified using "
+ "--dimension (-d) option. Threshold can also be specified with the "
+ "--threshold (-t) option; The default is 0.0."
+ "\n\n"
+ "The program does not modify the original file, but instead makes a "
+ "separate file to save the binarized data; The program requires you to "
+ "specify the file name with --output_file (-o)."
+ "\n\n"
+ "For example, if we want to make all variables greater than 5 in dataset "
+ "to 1 and ones that are less than or equal to 5.0 to 0, and save the "
+ "result to result.csv, we could run"
+ "\n\n"
+ "$ mlpack_preprocess_binarize -i dataset.csv -t 5 -o result.csv"
+ "\n\n"
+ "But if we want to apply this to only the first (0th) dimension of the "
+ "dataset, we could run"
+ "\n\n"
+ "$ mlpack_preprocess_binarize -i dataset.csv -t 5 -d 0 -o result.csv");
+
+// Define parameters for data.
+PARAM_STRING_REQ("input_file", "File containing data.", "i");
+// Define optional parameters.
+PARAM_STRING("output_file", "File to save the output.", "o");
+PARAM_INT("dimension", "Dimension to apply the binarization. If not set, the"
+ " program will binarize every dimension by default.", "d", 0);
+PARAM_DOUBLE("threshold", "Threshold to be applied for binarization. If not "
+ "set, the threshold defaults to 0.0.", "t", 0.0);
+
+using namespace mlpack;
+using namespace arma;
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ // Parse command line options.
+ CLI::ParseCommandLine(argc, argv);
+ const string inputFile = CLI::GetParam<string>("input_file");
+ const string outputFile = CLI::GetParam<string>("output_file");
+ const size_t dimension = (size_t) CLI::GetParam<int>("dimension");
+ const double threshold = CLI::GetParam<double>("threshold");
+
+ // Check on data parameters.
+ if (!CLI::HasParam("dimension"))
+ Log::Warn << "You did not specify --dimension, so the program will perform "
+ << "binarize on every dimensions." << endl;
+
+ if (!CLI::HasParam("threshold"))
+ Log::Warn << "You did not specify --threshold, so the threshold will be "
+ << "automatically set to '0.0'." << endl;
+
+ if (!CLI::HasParam("output_file"))
+ Log::Warn << "You did not specify --output_file, so no result will be "
+ << "saved." << endl;
+
+ // Load the data.
+ arma::mat input;
+ arma::mat output;
+ data::Load(inputFile, input, true);
+
+ Timer::Start("binarize");
+ if (CLI::HasParam("dimension"))
+ {
+ data::Binarize<double>(input, output, threshold, dimension);
+ }
+ else
+ {
+ // binarize the whole data
+ data::Binarize<double>(input, output, threshold);
+ }
+ Timer::Stop("binarize");
+
+ if (CLI::HasParam("output_file"))
+ data::Save(outputFile, output, false);
+}
diff --git a/src/mlpack/methods/preprocess/preprocess_split_main.cpp b/src/mlpack/methods/preprocess/preprocess_split_main.cpp
index c87dab9..f7f953b 100644
--- a/src/mlpack/methods/preprocess/preprocess_split_main.cpp
+++ b/src/mlpack/methods/preprocess/preprocess_split_main.cpp
@@ -74,29 +74,36 @@ int main(int argc, char** argv)
const string testLabelsFile = CLI::GetParam<string>("test_labels_file");
const double testRatio = CLI::GetParam<double>("test_ratio");
+ // Make sure the user specified output filenames.
+ if (trainingFile == "")
+ Log::Warn << "--training_file (-t) is not specified; no training set will "
+ << "be saved!" << endl;
+ if (testFile == "")
+ Log::Warn << "--test_file (-T) is not specified; no test set will be saved!"
+ << endl;
+
// Check on label parameters.
if (CLI::HasParam("input_labels"))
{
if (!CLI::HasParam("training_labels_file"))
{
- Log::Fatal << "--training_labels_file (-l) must be specified if "
- << "--input_labels (-l) is specified!" << endl;
+ Log::Warn << "--training_labels_file (-l) is not specified; no training "
+ << "set labels will be saved!" << endl;
}
if (!CLI::HasParam("test_labels_file"))
{
- Log::Fatal << "--test_labels_file (-L) must be specified if "
- << "--input_labels (-I) is specified!" << endl;
+ Log::Warn << "--test_labels_file (-L) is not specified; no test set "
+ << "labels will be saved!" << endl;
}
}
else
{
- if (CLI::HasParam("training_labels_file") ||
- CLI::HasParam("test_labels_file"))
- {
- Log::Fatal << "When specifying --training_labels_file or "
- << "--test_labels_file, you must also specify --input_labels."
- << endl;
- }
+ if (CLI::HasParam("training_labels_file"))
+ Log::Warn << "--training_labels_file ignored because --input_labels is "
+ << "not specified." << endl;
+ if (CLI::HasParam("test_labels_file"))
+ Log::Warn << "--test_labels_file ignored because --input_labels is not "
+ << "specified." << endl;
}
// Check test_ratio.
@@ -131,10 +138,14 @@ int main(int argc, char** argv)
Log::Info << "Test data contains " << get<1>(value).n_cols << " points."
<< endl;
- data::Save(trainingFile, get<0>(value), false);
- data::Save(testFile, get<1>(value), false);
- data::Save(trainingLabelsFile, get<2>(value), false);
- data::Save(testLabelsFile, get<3>(value), false);
+ if (trainingFile != "")
+ data::Save(trainingFile, get<0>(value), false);
+ if (testFile != "")
+ data::Save(testFile, get<1>(value), false);
+ if (trainingLabelsFile != "")
+ data::Save(trainingLabelsFile, get<2>(value), false);
+ if (testLabelsFile != "")
+ data::Save(testLabelsFile, get<3>(value), false);
}
else // We have no labels, so just split the dataset.
{
@@ -144,7 +155,9 @@ int main(int argc, char** argv)
Log::Info << "Test data contains " << get<1>(value).n_cols << " points."
<< endl;
- data::Save(trainingFile, get<0>(value), false);
- data::Save(testFile, get<1>(value), false);
+ if (trainingFile != "")
+ data::Save(trainingFile, get<0>(value), false);
+ if (testFile != "")
+ data::Save(testFile, get<1>(value), false);
}
}
diff --git a/src/mlpack/methods/radical/radical_main.cpp b/src/mlpack/methods/radical/radical_main.cpp
index 0a15cc5..1b76567 100644
--- a/src/mlpack/methods/radical/radical_main.cpp
+++ b/src/mlpack/methods/radical/radical_main.cpp
@@ -23,8 +23,17 @@ PROGRAM_INFO("RADICAL", "An implementation of RADICAL, a method for independent"
PARAM_STRING_REQ("input_file", "Input dataset filename for ICA.", "i");
-PARAM_STRING_REQ("output_ic", "File to save independent components to.", "o");
-PARAM_STRING_REQ("output_unmixing", "File to save unmixing matrix to.", "u");
+// Kept for reverse compatibility until mlpack 3.0.0.
+PARAM_STRING("output_ic", "File to save independent components to "
+ "(deprecated: use --output_ic_file).", "", "");
+PARAM_STRING("output_unmixing", "File to save unmixing matrix to "
+ "(deprecated: use --output_unmixing_file).", "", "");
+
+// These are the new parameter names.
+PARAM_STRING("output_ic_file", "File to save independent components to.",
+ "o", "");
+PARAM_STRING("output_unmixing_file", "File to save unmixing matrix to.",
+ "u", "");
PARAM_DOUBLE("noise_std_dev", "Standard deviation of Gaussian noise.", "n",
0.175);
@@ -49,12 +58,42 @@ int main(int argc, char* argv[])
// Handle parameters.
CLI::ParseCommandLine(argc, argv);
+ // Reverse compatibility. We can remove these for mlpack 3.0.0.
+ if (CLI::HasParam("output_ic") && CLI::HasParam("output_ic_file"))
+ Log::Fatal << "Cannot specify both --output_ic and --output_ic_file!"
+ << endl;
+
+ if (CLI::HasParam("output_unmixing") && CLI::HasParam("output_unmixing_file"))
+ Log::Fatal << "Cannot specify both --output_unmixing and "
+ << "--output_unmixing_file!" << endl;
+
+ if (CLI::HasParam("output_ic"))
+ {
+ Log::Warn << "--output_ic is deprecated and will be removed in mlpack "
+ << "3.0.0; use --output_ic_file instead." << endl;
+ CLI::GetParam<string>("output_ic_file") =
+ CLI::GetParam<string>("output_ic");
+ }
+
+ if (CLI::HasParam("output_unmixing"))
+ {
+ Log::Warn << "--output_unmixing is deprecated and will be removed in mlpack"
+ << " 3.0.0; use --output_unmixing_file instead." << endl;
+ CLI::GetParam<string>("output_unmixing_file") =
+ CLI::GetParam<string>("output_unmixing");
+ }
+
// Set random seed.
if (CLI::GetParam<int>("seed") != 0)
RandomSeed((size_t) CLI::GetParam<int>("seed"));
else
RandomSeed((size_t) std::time(NULL));
+ if ((CLI::GetParam<string>("output_ic_file") == "") &&
+ (CLI::GetParam<string>("output_unmixing_file") == ""))
+ Log::Warn << "Neither --output_ic_file nor --output_unmixing_file were "
+ << "specified; no output will be saved!" << endl;
+
// Load the data.
const string matXFilename = CLI::GetParam<string>("input_file");
mat matX;
@@ -78,11 +117,13 @@ int main(int argc, char* argv[])
rad.DoRadical(matX, matY, matW);
// Save results.
- const string matYFilename = CLI::GetParam<string>("output_ic");
- data::Save(matYFilename, matY);
+ const string matYFilename = CLI::GetParam<string>("output_ic_file");
+ if (matYFilename != "")
+ data::Save(matYFilename, matY);
- const string matWFilename = CLI::GetParam<string>("output_unmixing");
- data::Save(matWFilename, matW);
+ const string matWFilename = CLI::GetParam<string>("output_unmixing_file");
+ if (matWFilename != "")
+ data::Save(matWFilename, matW);
if (CLI::HasParam("objective"))
{
diff --git a/src/mlpack/methods/softmax_regression/softmax_regression_main.cpp b/src/mlpack/methods/softmax_regression/softmax_regression_main.cpp
index 39ce2a2..71a7964 100644
--- a/src/mlpack/methods/softmax_regression/softmax_regression_main.cpp
+++ b/src/mlpack/methods/softmax_regression/softmax_regression_main.cpp
@@ -117,7 +117,8 @@ int main(int argc, char** argv)
Log::Fatal << "One of --input_model_file or --training_file must be specified."
<< endl;
- if (CLI::HasParam("training_file") && CLI::HasParam("labels_file"))
+ if ((CLI::HasParam("training_file") || CLI::HasParam("labels_file")) &&
+ !(CLI::HasParam("training_file") && CLI::HasParam("labels_file")))
Log::Fatal << "--labels_file must be specified with --training_file!"
<< endl;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git
More information about the debian-science-commits
mailing list