[mlpack-svn] r13809 - mlpack/trunk/src/mlpack/methods/nca
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Oct 31 17:29:13 EDT 2012
Author: rcurtin
Date: 2012-10-31 17:29:13 -0400 (Wed, 31 Oct 2012)
New Revision: 13809
Modified:
mlpack/trunk/src/mlpack/methods/nca/nca_main.cpp
Log:
Also support a random seed.
Modified: mlpack/trunk/src/mlpack/methods/nca/nca_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/nca/nca_main.cpp 2012-10-31 21:27:41 UTC (rev 13808)
+++ mlpack/trunk/src/mlpack/methods/nca/nca_main.cpp 2012-10-31 21:29:13 UTC (rev 13809)
@@ -27,14 +27,15 @@
PARAM_STRING_REQ("output_file", "Output file for learned distance matrix.",
"o");
PARAM_STRING("labels_file", "File of labels for input dataset.", "l", "");
-PARAM_DOUBLE("step_size", "Step size for stochastic gradient descent.", "s",
- 0.01);
+PARAM_DOUBLE("step_size", "Step size for stochastic gradient descent (alpha).",
+ "a", 0.01);
PARAM_INT("max_iterations", "Maximum number of iterations for stochastic "
"gradient descent (0 indicates no limit).", "n", 500000);
PARAM_DOUBLE("tolerance", "Maximum tolerance for termination of stochastic "
"gradient descent.", "t", 1e-7);
PARAM_FLAG("normalize", "Normalize data; useful for datasets where points are "
"far apart, or when SGD is converging to an objective of NaN.", "N");
+PARAM_INT("seed", "Random seed. If 0, 'std::time(NULL)' is used.", "s", 0);
using namespace mlpack;
using namespace mlpack::nca;
@@ -47,6 +48,11 @@
// Parse command line.
CLI::ParseCommandLine(argc, argv);
+ if (CLI::GetParam<int>("seed") != 0)
+ math::RandomSeed((size_t) CLI::GetParam<int>("seed"));
+ else
+ math::RandomSeed((size_t) std::time(NULL));
+
const string inputFile = CLI::GetParam<string>("input_file");
const string labelsFile = CLI::GetParam<string>("labels_file");
const string outputFile = CLI::GetParam<string>("output_file");
More information about the mlpack-svn
mailing list