26 int main(
int argc,
char *argv[]) {
28 using namespace kaldi;
33 "This program can used when transferring a neural net from one language\n" 34 "to another (or one tree to another). It takes a neural net and a\n" 35 "transition model from a different neural net, resizes the last layer\n" 36 "to match the new transition model, zeroes it, and writes out the new,\n" 37 "resized .mdl file. If the original model had been 'mixed-up', the associated\n" 38 "SumGroupComponent will be removed.\n" 40 "Usage: nnet-am-reinitialize [options] <nnet-in> <new-transition-model> <nnet-out>\n" 42 " nnet-am-reinitialize 1.mdl exp/tri6/final.mdl 2.mdl\n";
44 bool binary_write =
true;
47 po.
Register(
"binary", &binary_write,
"Write output in binary mode");
56 std::string nnet_rxfilename = po.
GetArg(1),
57 transition_model_rxfilename = po.
GetArg(2),
58 nnet_wxfilename = po.
GetArg(3);
64 Input ki(nnet_rxfilename, &binary);
75 Output ko(nnet_wxfilename, binary_write);
79 KALDI_LOG <<
"Resized neural net from " << nnet_rxfilename
81 <<
" pdfs, and wrote to " << nnet_wxfilename;
83 }
catch(
const std::exception &e) {
84 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)
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 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
void ResizeOutputLayer(int32 new_num_pdfs)
This function is used when doing transfer learning to a new system.
int main(int argc, char *argv[])