27 int main(
int argc, 
char *argv[]) {
    29     using namespace kaldi;
    34         "Copy a raw neural net (this version works on raw nnet2 neural nets,\n"    35         "without the transition model.  Supports the 'truncate' option.\n"    37         "Usage:  raw-nnet-copy [options] <raw-nnet-in> <raw-nnet-out>\n"    39         " raw-nnet-copy --binary=false 1.mdl text.mdl\n"    40         "See also: nnet-to-raw-nnet, nnet-am-copy\n";
    43     bool binary_write = 
true;
    44     std::string learning_rate_scales_str = 
" ";
    47     po.
Register(
"binary", &binary_write, 
"Write output in binary mode");
    48     po.
Register(
"truncate", &truncate, 
"If set, will truncate the neural net "    49                 "to this many components by removing the last components.");
    50     po.
Register(
"learning-rate-scales", &learning_rate_scales_str,
    51                 "Colon-separated list of scaling factors for learning rates, "    52                 "applied after the --learning-rate and --learning-rates options."    53                 "Used to scale learning rates for particular layer types.  E.g."    54                 "--learning-rate-scales=AffineComponent=0.5");
    63     std::string raw_nnet_rxfilename = po.
GetArg(1),
    64         raw_nnet_wxfilename = po.
GetArg(2);
    72     if (learning_rate_scales_str != 
" ")  {
    74       std::map<std::string, BaseFloat> learning_rate_scales;
    75       std::vector<std::string> learning_rate_scale_vec;
    77                           &learning_rate_scale_vec);
    78       for (int32 index = 0; index < learning_rate_scale_vec.size();
    80         std::vector<std::string> parts;
    85           KALDI_ERR << 
"Unknown format for --learning-rate-scales option. "    86               << 
"Expected format is "    87               << 
"--learning-rate-scales=AffineComponent=0.1:AffineComponentPreconditioned=0.5 "    89               << learning_rate_scales_str;
    91         learning_rate_scales.insert(std::pair<std::string, BaseFloat>(
    92                 parts[0], scale_factor));
   100     KALDI_LOG << 
"Copied raw neural net from " << raw_nnet_rxfilename
   101               << 
" to " << raw_nnet_wxfilename;
   103   } 
catch(
const std::exception &e) {
   104     std::cerr << e.what() << 
'\n';
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
int main(int argc, char *argv[])
 
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor]. 
 
void Resize(int32 num_components)
Removes final components from the neural network (used for debugging). 
 
void Register(const std::string &name, bool *ptr, const std::string &doc)
 
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
 
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
 
void SplitStringToVector(const std::string &full, const char *delim, bool omit_empty_strings, std::vector< std::string > *out)
Split a string using any of the single character delimiters. 
 
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables. 
 
bool ConvertStringToReal(const std::string &str, T *out)
ConvertStringToReal converts a string into either float or double and returns false if there was any ...
 
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility. 
 
int NumArgs() const
Number of positional parameters (c.f. argc-1). 
 
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
 
void ScaleLearningRates(BaseFloat factor)
Scale all the learning rates in the neural net by this factor.