67     using namespace kaldi;
    70     typedef kaldi::int64 int64;
    73         "Copy examples for discriminative neural\n"    74         "network training.  Supports multiple wspecifiers, in\n"    75         "which case it will write the examples round-robin to the outputs.\n"    77         "Usage:  nnet-copy-egs-discriminative [options] <egs-rspecifier> <egs-wspecifier1> [<egs-wspecifier2> ...]\n"    80         "nnet-copy-egs-discriminative ark:train.degs ark,t:text.degs\n"    82         "nnet-copy-egs-discriminative ark:train.degs ark:1.degs ark:2.degs\n";
    87     int32 const_feat_dim = 0;
    90     po.Register(
"random", &random, 
"If true, will write frames to output "    91                 "archives randomly, not round-robin.");
    92     po.Register(
"keep-proportion", &keep_proportion, 
"If <1.0, this program will "    93                 "randomly keep this proportion of the input samples.  If >1.0, it will "    94                 "in expectation copy a sample this many times.  It will copy it a number "    95                 "of times equal to floor(keep-proportion) or ceil(keep-proportion).");
    96     po.Register(
"srand", &srand_seed, 
"Seed for random number generator "    97                 "(only relevant if --random=true or --keep-proportion != 1.0)");
    98     po.Register(
"const-feat-dim", &const_feat_dim,
    99                 "Dimension of part of features (last dims) which varies little "   100                 "or not at all with time, and which should be stored as a single "   101                 "vector for each example rather than in the feature matrix."   102                 "Useful in systems that use iVectors.  Helpful to save space.");
   108     if (po.NumArgs() < 2) {
   113     std::string examples_rspecifier = po.GetArg(1);
   116         examples_rspecifier);
   118     int32 num_outputs = po.NumArgs() - 1;
   119     std::vector<DiscriminativeNnetExampleWriter*> example_writers(num_outputs);
   120     for (int32 
i = 0; 
i < num_outputs; 
i++)
   125     int64 num_read = 0, num_written = 0, num_frames_written = 0;
   126     for (; !example_reader.Done(); example_reader.Next(), num_read++) {
   128       for (int32 c = 0; c < 
count; c++) {
   129         int32 index = (random ? 
Rand() : num_written) % num_outputs;
   130         std::ostringstream ostr;
   132         if (const_feat_dim == 0) {
   133           example_writers[index]->Write(ostr.str(),
   134                                         example_reader.Value());
   138           example_writers[index]->Write(ostr.str(), eg);
   141         num_frames_written +=
   142             static_cast<int64
>(example_reader.Value().num_ali.size());
   146     for (int32 
i = 0; 
i < num_outputs; 
i++)
   147       delete example_writers[
i];
   148     KALDI_LOG << 
"Read " << num_read << 
" discriminative neural-network training"   149               << 
" examples, wrote " << num_written << 
", consisting of "   150               << num_frames_written << 
" frames.";
   151     return (num_written == 0 ? 1 : 0);
   152   } 
catch(
const std::exception &e) {
   153     std::cerr << e.what() << 
'\n';
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
void AverageConstPart(int32 const_feat_dim, DiscriminativeNnetExample *eg)
 
TableWriter< KaldiObjectHolder< DiscriminativeNnetExample > > DiscriminativeNnetExampleWriter
 
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...
 
int Rand(struct RandomState *state)
 
This struct is used to store the information we need for discriminative training (MMI or MPE)...
 
int32 GetCount(double expected_count)