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");
51 if (po.NumArgs() != 3) {
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);
65 orig_trans_model.
Read(ki.Stream(), binary);
66 am_nnet.
Read(ki.Stream(), binary);
75 Output ko(nnet_wxfilename, binary_write);
76 new_trans_model.
Write(ko.Stream(), binary_write);
77 am_nnet.
Write(ko.Stream(), 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 Read(std::istream &is, bool binary)
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
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.