27 int main(
int argc,
char *argv[]) {
29 using namespace kaldi;
32 typedef kaldi::int64 int64;
35 "Train the neural network parameters with a discriminative objective\n" 36 "function (MMI, SMBR or MPFE). This uses training examples prepared with\n" 37 "nnet-get-egs-discriminative\n" 39 "Usage: nnet-train-discriminative-simple [options] <model-in> <training-examples-in> <model-out>\n" 41 "nnet-train-discriminative-simple 1.nnet ark:1.degs 2.nnet\n";
43 bool binary_write =
true;
44 std::string use_gpu =
"yes";
48 po.
Register(
"binary", &binary_write,
"Write output in binary mode");
50 "yes|no|optional|wait, only has effect if compiled with CUDA");
61 CuDevice::Instantiate().SelectGpuId(use_gpu);
64 std::string nnet_rxfilename = po.
GetArg(1),
65 examples_rspecifier = po.
GetArg(2),
66 nnet_wxfilename = po.
GetArg(3);
68 int64 num_examples = 0;
75 Input ki(nnet_rxfilename, &binary_read);
84 for (; !example_reader.
Done(); example_reader.
Next(), num_examples++) {
86 example_reader.
Value(),
88 if (num_examples % 10 == 0 && num_examples != 0) {
98 Output ko(nnet_wxfilename, binary_write);
104 CuDevice::Instantiate().PrintProfile();
106 KALDI_LOG <<
"Finished training, processed " << num_examples
107 <<
" training examples. Wrote model to " 109 return (num_examples == 0 ? 1 : 0);
110 }
catch(
const std::exception &e) {
111 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].
int32 GetVerboseLevel()
Get verbosity level, usually set via command line '–verbose=' switch.
void Read(std::istream &is, bool binary)
void Register(const std::string &name, bool *ptr, const std::string &doc)
void Register(OptionsItf *opts)
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
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
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 Print(std::string criterion)
int main(int argc, char *argv[])
void Write(std::ostream &os, bool binary) const
const Nnet & GetNnet() const
void NnetDiscriminativeUpdate(const AmNnet &am_nnet, const TransitionModel &tmodel, const NnetDiscriminativeUpdateOptions &opts, const DiscriminativeNnetExample &eg, Nnet *nnet_to_update, NnetDiscriminativeStats *stats)
Does the neural net computation, lattice forward-backward, and backprop, for either the MMI...