68 using namespace kaldi;
71 typedef kaldi::int64 int64;
74 "Read input nnet training examples, and compute the output for each one.\n" 75 "If --apply-exp=true, apply the Exp() function to the output before writing\n" 78 "Usage: nnet3-compute-from-egs [options] <raw-nnet-in> <training-examples-in> <matrices-out>\n" 80 "nnet3-compute-from-egs --apply-exp=true 0.raw ark:1.egs ark:- | matrix-sum-rows ark:- ... \n" 81 "See also: nnet3-compute\n";
83 bool binary_write =
true,
85 std::string use_gpu =
"yes";
86 std::string output_name =
"output";
89 po.Register(
"binary", &binary_write,
"Write output in binary mode");
90 po.Register(
"apply-exp", &apply_exp,
"If true, apply exp function to " 92 po.Register(
"output-name", &output_name,
"Do computation for " 93 "specified output-node");
94 po.Register(
"use-gpu", &use_gpu,
95 "yes|no|optional|wait, only has effect if compiled with CUDA");
99 if (po.NumArgs() != 3) {
105 CuDevice::Instantiate().SelectGpuId(use_gpu);
108 std::string nnet_rxfilename = po.GetArg(1),
109 examples_rspecifier = po.GetArg(2),
110 matrix_wspecifier = po.GetArg(3);
122 for (; !example_reader.Done(); example_reader.Next(), num_egs++) {
124 computer.Compute(example_reader.Value(), output_name, &output);
128 matrix_writer.Write(example_reader.Key(), output);
131 CuDevice::Instantiate().PrintProfile();
133 KALDI_LOG <<
"Processed " << num_egs <<
" examples.";
135 }
catch(
const std::exception &e) {
136 std::cerr << e.what() <<
'\n';
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
A templated class for writing objects to an archive or script file; see The Table concept...
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...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).