[mlpack-svn] [MLPACK] #150: inappropriate mixture of interfaces

MLPACK Trac trac at coffeetalk-1.cc.gatech.edu
Wed Oct 26 16:47:31 EDT 2011


#150: inappropriate mixture of interfaces
-------------------------------------------------------------------------------------------------------------------+
  Reporter:  nslagle                                                                                               |        Owner:            
      Type:  defect                                                                                                |       Status:  new       
  Priority:  major                                                                                                 |    Milestone:  MLPACK 1.0
 Component:  MLPACK                                                                                                |   Resolution:            
  Keywords:  neighbor_search, mog, emst, fastica, svm, regression, nnsvm, mvu, interfaces, command line interface  |     Blocking:            
Blocked By:                                                                                                        |  
-------------------------------------------------------------------------------------------------------------------+

Comment (by rcurtin):

 Here is some clarification from our 150-minute discussion today (for
 future reference and for anyone else who might be reading).

 We will not use any calls to `CLI::GetParam<>` inside anything other than
 a `main()` function.  While the `CLI` class before provided support such
 that you could simplify `main()` significantly, this carries too many
 dangers.

 A `main()` function should look like this (I'm using the MVU example):

 {{{
 int main(int argc, char** argv) {
   CLI::ParseCommandLine(argc, argv);

   // We must (unfortunately) tediously set every parameter.
   double lbfgs_param_1 = CLI::GetParam<double>("lbfgs/param_1");
   double lbfgs_param_2 = CLI::GetParam<double>("lbfgs/param_2");
   ...
   double auglag_param_1 = CLI::GetParam<double>("auglag/param_1");
   double auglag_param_2 = CLI::GetParam<double>("auglag/param_2");
   ...
   double mvu_param_1 = CLI::GetParam<double>("mvu/param_1");
   double mvu_param_2 = CLI::GetParam<double>("mvu/param_2");

   // Some parameters require sanity checks (but not all of them will).
   std::string input_file = CLI::GetParam<std::string>("input_file");
   if (input_file == "")
     Log::Fatal << "No input file specified!" << std::endl;
   // The output file has a default (output.csv) so we don't need to check
 it.
   std::string output_file = CLI::GetParam<std::string>("output_file");

   // Load the data.
   arma::mat dataset;
   dataset.load(input_file);

   // Create the classes.
   L_BFGS lbfgs(lbfgs_param_1, lbfgs_param_2, ...);
   AugLagrangian auglag(lbfgs, auglag_param_1, auglag_param_2, ...);
   MVU mvu(dataset, auglag, mvu_param_1, mvu_param_2, ...);

   // Run the method.
   arma::mat output;
   mvu.Unfold(output);

   output.save(output_file);
 }
 }}}

 That's kind of a big example, but what I am getting at is that `main()`
 functions must get all the parameters from `CLI` and sanity check them in
 `main()`.

 This unfortunately means that each parameter in the entire hierarchy must
 be checked, which is tedious.  Any methods we release an executable for,
 we must verify that every possible option is specified.  This could be
 done with a script as a post-commit hook or just by inspection.

 So, the main.cpp files will get more complex, but that's how it goes, I
 guess.

-- 
Ticket URL: <https://trac.research.cc.gatech.edu/fastlab/ticket/150#comment:14>
MLPACK <www.fast-lab.org>
MLPACK is an intuitive, fast, and scalable C++ machine learning library developed by the FASTLAB at Georgia Tech under Dr. Alex Gray.


More information about the mlpack-svn mailing list