[mlpack-svn] r11165 - mlpack/trunk/src/mlpack/methods/hmm

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Jan 19 11:39:39 EST 2012


Author: rcurtin
Date: 2012-01-19 11:39:39 -0500 (Thu, 19 Jan 2012)
New Revision: 11165

Modified:
   mlpack/trunk/src/mlpack/methods/hmm/hmm_generate_main.cpp
   mlpack/trunk/src/mlpack/methods/hmm/hmm_train_main.cpp
Log:
Add support for --seed to HMM executables (where necessary).


Modified: mlpack/trunk/src/mlpack/methods/hmm/hmm_generate_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/hmm/hmm_generate_main.cpp	2012-01-19 16:35:17 UTC (rev 11164)
+++ mlpack/trunk/src/mlpack/methods/hmm/hmm_generate_main.cpp	2012-01-19 16:39:39 UTC (rev 11165)
@@ -21,11 +21,12 @@
 PARAM_STRING_REQ("model_file", "File containing HMM (XML).", "m");
 PARAM_INT_REQ("length", "Length of sequence to generate.", "l");
 
-PARAM_INT("start_state", "Starting state of sequence.", "S", 0);
+PARAM_INT("start_state", "Starting state of sequence.", "t", 0);
 PARAM_STRING("output_file", "File to save observation sequence to.", "o",
     "output.csv");
 PARAM_STRING("state_file", "File to save hidden state sequence to (may be left "
-    "unspecified.", "s", "");
+    "unspecified.", "S", "");
+PARAM_INT("seed", "Random seed.  If 0, 'std::time(NULL)' is used.", "s", 0);
 
 using namespace mlpack;
 using namespace mlpack::hmm;
@@ -40,6 +41,12 @@
   // Parse command line options.
   CLI::ParseCommandLine(argc, argv);
 
+  // Set random seed.
+  if (CLI::GetParam<int>("seed") != 0)
+    math::RandomSeed((size_t) CLI::GetParam<int>("seed"));
+  else
+    math::RandomSeed((size_t) std::time(NULL));
+
   // Load observations.
   const string modelFile = CLI::GetParam<string>("model_file");
   const int length = CLI::GetParam<int>("length");

Modified: mlpack/trunk/src/mlpack/methods/hmm/hmm_train_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/hmm/hmm_train_main.cpp	2012-01-19 16:35:17 UTC (rev 11164)
+++ mlpack/trunk/src/mlpack/methods/hmm/hmm_train_main.cpp	2012-01-19 16:39:39 UTC (rev 11165)
@@ -33,7 +33,7 @@
     "expected to contain a list of files to use as input observation sequences "
     " (and label sequences).", "b");
 PARAM_INT("states", "Number of hidden states in HMM (necessary, unless "
-    "model_file is specified.", "s", 0);
+    "model_file is specified.", "n", 0);
 PARAM_INT("gaussians", "Number of gaussians in each GMM (necessary when type is"
     " 'gmm'.", "g", 0);
 PARAM_STRING("model_file", "Pre-existing HMM model (optional).", "m", "");
@@ -41,6 +41,7 @@
     "labeled training.", "l", "");
 PARAM_STRING("output_file", "File to save trained HMM to (XML).", "o",
     "output_hmm.xml");
+PARAM_INT("seed", "Random seed.  If 0, 'std::time(NULL)' is used.", "s", 0);
 
 using namespace mlpack;
 using namespace mlpack::hmm;
@@ -55,6 +56,12 @@
   // Parse command line options.
   CLI::ParseCommandLine(argc, argv);
 
+  // Set random seed.
+  if (CLI::GetParam<int>("seed") != 0)
+    math::RandomSeed((size_t) CLI::GetParam<int>("seed"));
+  else
+    math::RandomSeed((size_t) std::time(NULL));
+
   // Validate parameters.
   const string inputFile = CLI::GetParam<string>("input_file");
   const string labelsFile = CLI::GetParam<string>("labels_file");




More information about the mlpack-svn mailing list