[mlpack-git] master: Add reverse compatibility for some incorrectly-named parameters. (846af86)
gitdub at mlpack.org
gitdub at mlpack.org
Fri Jul 15 11:41:07 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/59bc0b32630a3ad786706993f4d5e8b087f1c702...0d9a0e263a32b99d8dcf5d2723b3b92c67e669fc
>---------------------------------------------------------------
commit 846af8610a10ae624e82a2b50e5cfdc3cec950d2
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.
>---------------------------------------------------------------
846af8610a10ae624e82a2b50e5cfdc3cec950d2
src/mlpack/core/util/cli.cpp | 12 +++++
src/mlpack/methods/lars/lars_main.cpp | 22 ++++----
.../linear_regression/linear_regression_main.cpp | 35 +++++++++++--
src/mlpack/methods/lsh/lsh_main.cpp | 6 +++
src/mlpack/methods/mean_shift/mean_shift_main.cpp | 59 +++++++++++++++++-----
src/mlpack/methods/nca/nca_main.cpp | 9 +++-
.../preprocess/preprocess_binarize_main.cpp | 14 ++---
.../methods/preprocess/preprocess_split_main.cpp | 45 ++++++++++-------
src/mlpack/methods/radical/radical_main.cpp | 49 +++++++++++++++---
.../softmax_regression/softmax_regression_main.cpp | 5 +-
10 files changed, 192 insertions(+), 64 deletions(-)
diff --git a/src/mlpack/core/util/cli.cpp b/src/mlpack/core/util/cli.cpp
index d009466..aa87167 100644
--- a/src/mlpack/core/util/cli.cpp
+++ b/src/mlpack/core/util/cli.cpp
@@ -487,6 +487,13 @@ void CLI::PrintOutput()
(data.name.substr(data.name.size() - 5, 5) == "_file"))
continue;
+ // Reverse compatibility; should be removed for mlpack 3.0.0. Don't print
+ // some options that have only been kept for reverse compatibility.
+ if (data.name == "output_predictions" ||
+ data.name == "output_ic" ||
+ data.name == "output_unmixing")
+ continue;
+
// Now, we must print it, so figure out what the type is.
if (data.tname == TYPENAME(std::string))
{
@@ -663,6 +670,11 @@ void CLI::PrintHelp(const std::string& param)
(data.name.substr(data.name.size() - 5, 5) != "_file")))
continue;
+ // 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 5bae11f..3bb6d3d 100644
--- a/src/mlpack/methods/lars/lars_main.cpp
+++ b/src/mlpack/methods/lars/lars_main.cpp
@@ -94,7 +94,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;
@@ -112,17 +114,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.
@@ -182,10 +186,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 f8336f2..cb14a16 100644
--- a/src/mlpack/methods/linear_regression/linear_regression_main.cpp
+++ b/src/mlpack/methods/linear_regression/linear_regression_main.cpp
@@ -37,8 +37,13 @@ PARAM_STRING_IN("input_model_file", "File containing existing model "
PARAM_STRING_OUT("output_model_file", "File to save trained model to.", "M");
PARAM_STRING_IN("test_file", "File containing X' (test regressors).", "T", "");
+
+// Keep for reverse compatibility. We can remove these for mlpack 3.0.0.
PARAM_STRING_OUT("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_OUT("output_predictions_file", "If --test_file is specified, this "
+ "file is where the predicted responses will be saved.", "o");
PARAM_DOUBLE_IN("lambda", "Tikhonov regularization for ridge regression. If 0,"
" the method reduces to linear regression.", "l", 0.0);
@@ -53,16 +58,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;
@@ -92,8 +116,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
@@ -111,7 +136,7 @@ int main(int argc, char* argv[])
if (outputModelFile == "" && outputPredictionsFile == "")
{
- Log::Warn << "Neither --output_model_file nor --output_predictions are "
+ Log::Warn << "Neither --output_model_file nor --output_predictions_file are "
<< "specified; no output will be saved!" << endl;
}
@@ -188,7 +213,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/lsh/lsh_main.cpp b/src/mlpack/methods/lsh/lsh_main.cpp
index 9d6ceee..308f8cb 100644
--- a/src/mlpack/methods/lsh/lsh_main.cpp
+++ b/src/mlpack/methods/lsh/lsh_main.cpp
@@ -48,6 +48,10 @@ PARAM_STRING_IN("input_model_file", "File to load LSH model from. (Cannot be "
"specified with --reference_file.)", "m", "");
PARAM_STRING_OUT("output_model_file", "File to save LSH model to.", "M");
+// For testing recall.
+PARAM_STRING_IN("true_neighbors_file", "File of true neighbors to compute "
+ "recall with (the recall is printed when -v is specified).", "t", "");
+
PARAM_INT_IN("k", "Number of nearest neighbors to find.", "k", 0);
PARAM_STRING_IN("query_file", "File containing query points (optional).", "q",
"");
@@ -58,6 +62,8 @@ PARAM_INT_IN("tables", "The number of hash tables to be used.", "L", 30);
PARAM_DOUBLE_IN("hash_width", "The hash width for the first-level hashing in "
"the LSH preprocessing. By default, the LSH class automatically estimates "
"a hash width for its use.", "H", 0.0);
+PARAM_INT_IN("num_probes", "Number of additional probes for multiprobe LSH; if "
+ "0, traditional LSH is used.", "T", 0);
PARAM_INT_IN("second_hash_size", "The size of the second level hash table.",
"S", 99901);
PARAM_INT_IN("bucket_size", "The size of a bucket in the second level hash.",
diff --git a/src/mlpack/methods/mean_shift/mean_shift_main.cpp b/src/mlpack/methods/mean_shift/mean_shift_main.cpp
index b5485e1..88de594 100644
--- a/src/mlpack/methods/mean_shift/mean_shift_main.cpp
+++ b/src/mlpack/methods/mean_shift/mean_shift_main.cpp
@@ -21,13 +21,18 @@ PROGRAM_INFO("Mean Shift Clustering", "This program performs mean shift "
"in a separate file.");
// Required options.
-PARAM_STRING_IN_REQ("inputFile", "Input dataset to perform clustering on.",
- "i");
+PARAM_STRING_IN("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_IN("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, "
"--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_OUT("output_file", "File to write output labels or labeled data "
"to.", "o");
PARAM_STRING_OUT("centroid_file", "If specified, the centroids of each cluster "
@@ -45,7 +50,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");
@@ -63,6 +82,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;
@@ -94,16 +117,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 583872d..c699c82 100644
--- a/src/mlpack/methods/nca/nca_main.cpp
+++ b/src/mlpack/methods/nca/nca_main.cpp
@@ -71,7 +71,7 @@ PROGRAM_INFO("Neighborhood Components Analysis (NCA)",
"By default, the SGD optimizer is used.");
PARAM_STRING_IN_REQ("input_file", "Input dataset to run NCA on.", "i");
-PARAM_STRING_IN_REQ("output_file", "Output file for learned distance matrix.",
+PARAM_STRING_OUT("output_file", "Output file for learned distance matrix.",
"o");
PARAM_STRING_IN("labels_file", "File of labels for input dataset.", "l", "");
PARAM_STRING_IN("optimizer", "Optimizer to use; 'sgd', 'minibatch-sgd', or "
@@ -125,6 +125,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") &&
@@ -280,5 +284,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/preprocess/preprocess_binarize_main.cpp b/src/mlpack/methods/preprocess/preprocess_binarize_main.cpp
index ed050f1..9faa815 100644
--- a/src/mlpack/methods/preprocess/preprocess_binarize_main.cpp
+++ b/src/mlpack/methods/preprocess/preprocess_binarize_main.cpp
@@ -29,13 +29,13 @@ PROGRAM_INFO("Binarize Data", "This utility takes a dataset and binarizes the "
"$ mlpack_preprocess_binarize -i dataset.csv -t 5 -d 0 -o result.csv");
// Define parameters for data.
-PARAM_STRING_IN_REQ("input_file", "File containing data,", "i");
+PARAM_STRING_IN_REQ("input_file", "File containing data.", "i");
// Define optional parameters.
-PARAM_STRING_OUT("output_file", "File to save the output,", "o");
+PARAM_STRING_OUT("output_file", "File to save the output.", "o");
PARAM_INT_IN("dimension", "Dimension to apply the binarization. If not set, the"
- " program will binarize every dimension by default", "d", 0);
+ " program will binarize every dimension by default.", "d", 0);
PARAM_DOUBLE_IN("threshold", "Threshold to be applied for binarization. If not "
- "set, the threshold defaults to 0.0", "t", 0.0);
+ "set, the threshold defaults to 0.0.", "t", 0.0);
using namespace mlpack;
using namespace arma;
@@ -56,11 +56,11 @@ int main(int argc, char** argv)
<< "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;
+ 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"
+ Log::Warn << "You did not specify --output_file, so no result will be "
<< "saved." << endl;
// Load the data.
diff --git a/src/mlpack/methods/preprocess/preprocess_split_main.cpp b/src/mlpack/methods/preprocess/preprocess_split_main.cpp
index 9ecfb70..6a5b149 100644
--- a/src/mlpack/methods/preprocess/preprocess_split_main.cpp
+++ b/src/mlpack/methods/preprocess/preprocess_split_main.cpp
@@ -70,33 +70,34 @@ int main(int argc, char** argv)
// Make sure the user specified output filenames.
if (trainingFile == "")
- Log::Fatal << "--training_file (-t) must be specified!" << endl;
+ Log::Warn << "--training_file (-t) is not specified; no training set will "
+ << "be saved!" << endl;
if (testFile == "")
- Log::Fatal << "--test_file (-T) must be specified!" << endl;
+ Log::Warn << "--test_file (-T) is not specified; no test set will be saved!"
+ << endl;
// Check on label parameters.
if (CLI::HasParam("input_labels_file"))
{
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 +132,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 +149,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 85206bb..544e7bc 100644
--- a/src/mlpack/methods/radical/radical_main.cpp
+++ b/src/mlpack/methods/radical/radical_main.cpp
@@ -16,8 +16,17 @@ PROGRAM_INFO("RADICAL", "An implementation of RADICAL, a method for independent"
PARAM_STRING_IN_REQ("input_file", "Input dataset filename for ICA.", "i");
-PARAM_STRING_OUT("output_ic", "File to save independent components to.", "o");
-PARAM_STRING_OUT("output_unmixing", "File to save unmixing matrix to.", "u");
+// Kept for reverse compatibility until mlpack 3.0.0.
+PARAM_STRING_OUT("output_ic", "File to save independent components to "
+ "(deprecated: use --output_ic_file).", "");
+PARAM_STRING_OUT("output_unmixing", "File to save unmixing matrix to "
+ "(deprecated: use --output_unmixing_file).", "");
+
+// These are the new parameter names.
+PARAM_STRING_OUT("output_ic_file", "File to save independent components to.",
+ "o");
+PARAM_STRING_OUT("output_unmixing_file", "File to save unmixing matrix to.",
+ "u");
PARAM_DOUBLE_IN("noise_std_dev", "Standard deviation of Gaussian noise.", "n",
0.175);
@@ -42,15 +51,41 @@ 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::HasParam("output_ic") && !CLI::HasParam("output_unmixing"))
- Log::Warn << "Neither --output_ic nor --output_unmixing were specified; "
- << "no output will be saved!" << endl;
+ 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");
@@ -75,11 +110,11 @@ int main(int argc, char* argv[])
rad.DoRadical(matX, matY, matW);
// Save results.
- const string matYFilename = CLI::GetParam<string>("output_ic");
+ const string matYFilename = CLI::GetParam<string>("output_ic_file");
if (matYFilename != "")
data::Save(matYFilename, matY);
- const string matWFilename = CLI::GetParam<string>("output_unmixing");
+ const string matWFilename = CLI::GetParam<string>("output_unmixing_file");
if (matWFilename != "")
data::Save(matWFilename, matW);
diff --git a/src/mlpack/methods/softmax_regression/softmax_regression_main.cpp b/src/mlpack/methods/softmax_regression/softmax_regression_main.cpp
index 701b964..2d8ade9 100644
--- a/src/mlpack/methods/softmax_regression/softmax_regression_main.cpp
+++ b/src/mlpack/methods/softmax_regression/softmax_regression_main.cpp
@@ -38,7 +38,7 @@ PROGRAM_INFO("Softmax Regression", "This program performs softmax regression, "
PARAM_STRING_IN("training_file", "A file containing the training set (the "
"matrix of predictors, X).", "t", "");
PARAM_STRING_IN("labels_file", "A file containing labels (0 or 1) for the "
- "points in the training set (y). The labels must order as a row", "l", "");
+ "points in the training set (y). The labels must order as a row.", "l", "");
// Model loading/saving.
PARAM_STRING_IN("input_model_file", "File containing existing model "
@@ -104,7 +104,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;
More information about the mlpack-git
mailing list