[mlpack-git] master: Allow the random seed to be set. (9e00b42)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Wed Jul 8 15:02:23 EDT 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/ca9c4c7d54e40516d87ccca3631a86148527b0a8...53a93a0e49ce0d472f1707b63f7659ceeb007c4f
>---------------------------------------------------------------
commit 9e00b42ece4a53864f5bc64a882f597d0eb33818
Author: Ryan Curtin <ryan at ratml.org>
Date: Wed Jul 8 18:56:03 2015 +0000
Allow the random seed to be set.
>---------------------------------------------------------------
9e00b42ece4a53864f5bc64a882f597d0eb33818
src/mlpack/methods/cf/cf_main.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/mlpack/methods/cf/cf_main.cpp b/src/mlpack/methods/cf/cf_main.cpp
index a870349..d4b5636 100644
--- a/src/mlpack/methods/cf/cf_main.cpp
+++ b/src/mlpack/methods/cf/cf_main.cpp
@@ -81,6 +81,8 @@ PARAM_FLAG("iteration_only_termination", "Terminate only when the maximum "
PARAM_DOUBLE("min_residue", "Residue required to terminate the factorization "
"(lower values generally mean better fits).", "r", 1e-5);
+PARAM_INT("seed", "Set the random seed (0 uses std::time(NULL)).", "s", 0);
+
template<typename Factorizer>
void ComputeRecommendations(CF<Factorizer>& cf,
const size_t numRecs,
@@ -231,6 +233,11 @@ int main(int argc, char** argv)
// Parse command line options.
CLI::ParseCommandLine(argc, argv);
+ if (CLI::GetParam<int>("seed") == 0)
+ math::RandomSeed(std::time(NULL));
+ else
+ math::RandomSeed(CLI::GetParam<int>("seed"));
+
// Read from the input file.
const string inputFile = CLI::GetParam<string>("input_file");
arma::mat dataset;
More information about the mlpack-git
mailing list