26 int main(
int argc, 
char *argv[]) {
    28     using namespace kaldi;
    33         "Copy a (cpu-based) neural net and its associated transition model,\n"    34         "and switch it to online preconditioning, i.e. change any components\n"    35         "derived from AffineComponent to components of type\n"    36         "AffineComponentPreconditionedOnline.\n"    38         "Usage:  nnet-am-switch-preconditioning [options] <nnet-in> <nnet-out>\n"    40         " nnet-am-switch-preconditioning --binary=false 1.mdl text.mdl\n";
    42     int32 rank_in = 20, rank_out = 80, update_period = 4;
    45     bool binary_write = 
true;
    48     po.
Register(
"binary", &binary_write, 
"Write output in binary mode");
    50                 "Rank used in online-preconditioning on input side of each layer");
    52                 "Rank used in online-preconditioning on output side of each layer");
    53     po.
Register(
"update-period", &update_period,
    54                 "Affects how frequently we update the Fisher-matrix estimate (every "    55                 "this-many minibatches).");
    56     po.
Register(
"num-samples-history", &num_samples_history,
    57                 "Number of samples of history to use in online preconditioning "    58                 "(affects speed vs accuracy of update of Fisher matrix)");
    60                 "Parameter that affects amount of smoothing with unit matrix "    61                 "in online preconditioning (larger -> more smoothing)");
    70     std::string nnet_rxfilename = po.
GetArg(1),
    71         nnet_wxfilename = po.
GetArg(2);
    77       Input ki(nnet_rxfilename, &binary);
    83                                                     num_samples_history, alpha);
    86       Output ko(nnet_wxfilename, binary_write);
    90     KALDI_LOG << 
"Copied neural net from " << nnet_rxfilename
    91               << 
" to " << nnet_wxfilename;
    93   } 
catch(
const std::exception &e) {
    94     std::cerr << e.what() << 
'\n';
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor]. 
 
void Read(std::istream &is, bool binary)
 
void Register(const std::string &name, bool *ptr, const std::string &doc)
 
int main(int argc, char *argv[])
 
void SwitchToOnlinePreconditioning(int32 rank_in, int32 rank_out, int32 update_period, BaseFloat num_samples_history, BaseFloat alpha)
Replaces any components of type AffineComponent or derived classes, with components of type AffineCom...
 
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
 
void Read(std::istream &is, bool binary)
 
void Write(std::ostream &os, bool binary) const
 
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables. 
 
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 Write(std::ostream &os, bool binary) const
 
const Nnet & GetNnet() const