All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
fmpe-est.cc File Reference
#include "base/kaldi-common.h"
#include "util/common-utils.h"
#include "transform/fmpe.h"
Include dependency graph for fmpe-est.cc:

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 24 of file fmpe-est.cc.

References FmpeStats::DoChecks(), ParseOptions::GetArg(), KALDI_LOG, ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), kaldi::ReadKaldiObject(), ParseOptions::Register(), FmpeUpdateOptions::Register(), Fmpe::Update(), and kaldi::WriteKaldiObject().

24  {
25  using namespace kaldi;
26  try {
27  const char *usage =
28  "Do one iteration of learning (modified gradient descent)\n"
29  "on fMPE transform\n"
30  "Usage: fmpe-est [options...] <fmpe-in> <stats-in> <fmpe-out>\n"
31  "E.g. fmpe-est 1.fmpe 1.accs 2.fmpe\n";
32 
33  ParseOptions po(usage);
34  FmpeUpdateOptions opts;
35  bool binary = true;
36  po.Register("binary", &binary, "If true, output fMPE object in "
37  "binary mode.");
38  opts.Register(&po);
39  po.Read(argc, argv);
40 
41  if (po.NumArgs() != 3) {
42  po.PrintUsage();
43  exit(1);
44  }
45 
46  std::string fmpe_rxfilename = po.GetArg(1),
47  stats_rxfilename = po.GetArg(2),
48  fmpe_wxfilename = po.GetArg(3);
49 
50  Fmpe fmpe;
51  ReadKaldiObject(fmpe_rxfilename, &fmpe);
52  FmpeStats stats;
53  ReadKaldiObject(stats_rxfilename, &stats);
54 
55  stats.DoChecks(); // checks certain checksums.
56  fmpe.Update(opts, stats);
57 
58  WriteKaldiObject(fmpe, fmpe_wxfilename, binary);
59 
60  KALDI_LOG << "Updated fMPE object and wrote to "
61  << fmpe_wxfilename;
62  return 0;
63  } catch(const std::exception &e) {
64  std::cerr << e.what();
65  return -1;
66  }
67 }
Relabels neural network egs with the read pdf-id alignments.
Definition: chain.dox:20
BaseFloat Update(const FmpeUpdateOptions &config, const FmpeStats &stats)
Definition: fmpe.cc:443
void Register(OptionsItf *opts)
Definition: fmpe.h:95
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
Definition: kaldi-io.cc:818
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
void DoChecks()
Definition: fmpe.cc:649
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Definition: kaldi-io.h:257
#define KALDI_LOG
Definition: kaldi-error.h:133