nnet-am-mixup.cc File Reference
Include dependency graph for nnet-am-mixup.cc:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 27 of file nnet-am-mixup.cc.

References ParseOptions::GetArg(), AmNnet::GetNnet(), KALDI_LOG, kaldi::nnet2::MixupNnet(), ParseOptions::NumArgs(), ParseOptions::PrintUsage(), AmNnet::Read(), ParseOptions::Read(), TransitionModel::Read(), NnetMixupConfig::Register(), Output::Stream(), Input::Stream(), AmNnet::Write(), and TransitionModel::Write().

27  {
28  try {
29  using namespace kaldi;
30  using namespace kaldi::nnet2;
31  typedef kaldi::int32 int32;
32 
33  const char *usage =
34  "Add mixture-components to a neural net (comparable to mixtures in a Gaussian\n"
35  "mixture model). Number of mixture components must be greater than the number\n"
36  "of pdfs\n"
37  "\n"
38  "Usage: nnet-am-mixup [options] <nnet-in> <nnet-out>\n"
39  "e.g.:\n"
40  " nnet-am-mixup --power=0.3 --num-mixtures=5000 1.mdl 2.mdl\n";
41 
42  NnetMixupConfig config;
43  bool binary_write = true;
44 
45  ParseOptions po(usage);
46  config.Register(&po);
47 
48  po.Read(argc, argv);
49 
50  if (po.NumArgs() != 2) {
51  po.PrintUsage();
52  exit(1);
53  }
54 
55  std::string nnet_rxfilename = po.GetArg(1),
56  nnet_wxfilename = po.GetArg(2);
57 
58  TransitionModel trans_model;
59  AmNnet am_nnet;
60  {
61  bool binary;
62  Input ki(nnet_rxfilename, &binary);
63  trans_model.Read(ki.Stream(), binary);
64  am_nnet.Read(ki.Stream(), binary);
65  }
66 
67  MixupNnet(config, &(am_nnet.GetNnet()));
68 
69  {
70  Output ko(nnet_wxfilename, binary_write);
71  trans_model.Write(ko.Stream(), binary_write);
72  am_nnet.Write(ko.Stream(), binary_write);
73  }
74  KALDI_LOG << "Mixed up neural net from " << nnet_rxfilename
75  << " and wrote it to " << nnet_wxfilename;
76  return 0;
77  } catch(const std::exception &e) {
78  std::cerr << e.what() << '\n';
79  return -1;
80  }
81 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void Read(std::istream &is, bool binary)
Definition: am-nnet.cc:39
kaldi::int32 int32
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
void Register(OptionsItf *opts)
Definition: mixup-nnet.h:40
void Read(std::istream &is, bool binary)
void Write(std::ostream &os, bool binary) const
Definition: am-nnet.cc:31
void Write(std::ostream &os, bool binary) const
#define KALDI_LOG
Definition: kaldi-error.h:153
const Nnet & GetNnet() const
Definition: am-nnet.h:61
void MixupNnet(const NnetMixupConfig &mixup_config, Nnet *nnet)
This function works as follows.
Definition: mixup-nnet.cc:86