27 int main(
int argc, 
char *argv[]) {
    29     using namespace kaldi;
    34         "This program is for adding new layers to a neural-network acoustic model.\n"    35         "It removes the last --remove-layers layers, and adds the layers from the\n"    36         "supplied raw-nnet.  The typical use is to remove the last two layers\n"    37         "(the softmax, and the affine component before it), and add in replacements\n"    38         "for them newly initialized by nnet-init.  This program is a more flexible\n"    39         "way of adding layers than nnet-insert, but the inserted network needs to\n"    40         "contain replacements for the removed layers.\n"    42         "Usage:  nnet-replace-last-layers [options] <nnet-in> <raw-nnet-to-insert-in> <nnet-out>\n"    44         " nnet-replace-last-layers 1.nnet \"nnet-init hidden_layer.config -|\" 2.nnet\n";
    46     bool binary_write = 
true;
    47     int32 remove_layers = 2;
    51     po.
Register(
"binary", &binary_write, 
"Write output in binary mode");
    52     po.
Register(
"remove-layers", &remove_layers, 
"Number of final layers "    53                 "to remove before adding input raw network.");
    62     std::string nnet_rxfilename = po.
GetArg(1),
    63         raw_nnet_rxfilename = po.
GetArg(2),
    64         nnet_wxfilename = po.
GetArg(3);
    70       Input ki(nnet_rxfilename, &binary);
    83     KALDI_LOG << 
"Removed " << remove_layers << 
" components and added "    87       Output ko(nnet_wxfilename, binary_write);
    91     KALDI_LOG << 
"Write neural-net acoustic model 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)
 
int main(int argc, char *argv[])
 
void Register(const std::string &name, bool *ptr, const std::string &doc)
 
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
 
int32 NumComponents() const
Returns number of components– think of this as similar to # of layers, but e.g. 
 
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. 
 
void ReplaceLastComponents(const Nnet &src_nnet, int32 num_to_remove, Nnet *dest_nnet)
Removes the last "num_to_remove" components and adds the components from "src_nnet". 
 
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