26 int main(
int argc,
char *argv[]) {
28 using namespace kaldi;
31 typedef kaldi::int64 int64;
34 "Computes and prints in logging messages the average log-prob per frame of\n" 35 "the given data with an nnet3 neural net. The input of this is the output of\n" 36 "e.g. nnet3-get-egs | nnet3-merge-egs.\n" 38 "Usage: nnet3-compute-prob [options] <raw-model-in> <training-examples-in>\n" 39 "e.g.: nnet3-compute-prob 0.raw ark:valid.egs\n";
42 bool batchnorm_test_mode =
true, dropout_test_mode =
true,
43 collapse_model =
true;
53 po.
Register(
"batchnorm-test-mode", &batchnorm_test_mode,
54 "If true, set test-mode to true on any BatchNormComponents.");
55 po.
Register(
"dropout-test-mode", &dropout_test_mode,
56 "If true, set test-mode to true on any DropoutComponents and " 57 "DropoutMaskComponents.");
58 po.
Register(
"collapse-model", &collapse_model,
59 "If true, collapse model to the extent possible before " 60 "using it (for efficiency).");
71 std::string raw_nnet_rxfilename = po.
GetArg(1),
72 examples_rspecifier = po.
GetArg(2);
77 if (batchnorm_test_mode)
80 if (dropout_test_mode)
90 for (; !example_reader.
Done(); example_reader.
Next())
96 }
catch(
const std::exception &e) {
97 std::cerr << e.what() <<
'\n';
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void CollapseModel(const CollapseModelConfig &config, Nnet *nnet)
This function modifies the neural net for efficiency, in a way that suitable to be done in test time...
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
void Compute(const NnetExample &eg)
void SetBatchnormTestMode(bool test_mode, Nnet *nnet)
This function affects only components of type BatchNormComponent.
This class is for computing cross-entropy and accuracy values in a neural network, for diagnostics.
void Register(const std::string &name, bool *ptr, const std::string &doc)
bool PrintTotalStats() const
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
This file contains some miscellaneous functions dealing with class Nnet.
void SetDropoutTestMode(bool test_mode, Nnet *nnet)
This function affects components of child-classes of RandomComponent.
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
void Register(OptionsItf *opts)
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 main(int argc, char *argv[])
int NumArgs() const
Number of positional parameters (c.f. argc-1).
Config class for the CollapseModel function.