All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ExampleGenerationConfig Struct Reference

#include <nnet-example-utils.h>

Collaboration diagram for ExampleGenerationConfig:

Public Member Functions

 ExampleGenerationConfig ()
 
void ComputeDerived ()
 This function decodes 'num_frames_str' into 'num_frames', and ensures that the members of 'num_frames' are multiples of 'frame_subsampling_factor'. More...
 
void Register (OptionsItf *po)
 

Public Attributes

int32 left_context
 
int32 right_context
 
int32 left_context_initial
 
int32 right_context_final
 
int32 num_frames_overlap
 
int32 frame_subsampling_factor
 
std::string num_frames_str
 
std::vector< int32 > num_frames
 

Detailed Description

Definition at line 82 of file nnet-example-utils.h.

Constructor & Destructor Documentation

Member Function Documentation

void ComputeDerived ( )

This function decodes 'num_frames_str' into 'num_frames', and ensures that the members of 'num_frames' are multiples of 'frame_subsampling_factor'.

Definition at line 302 of file nnet-example-utils.cc.

References ExampleGenerationConfig::frame_subsampling_factor, rnnlm::i, KALDI_ERR, KALDI_LOG, ExampleGenerationConfig::num_frames, ExampleGenerationConfig::num_frames_str, and kaldi::SplitStringToIntegers().

Referenced by main().

302  {
303  if (!SplitStringToIntegers(num_frames_str, ",", false, &num_frames) ||
304  num_frames.empty()) {
305  KALDI_ERR << "Invalid option (expected comma-separated list of integers): "
306  << "--num-frames=" << num_frames_str;
307  }
308 
309  int32 m = frame_subsampling_factor;
310  if (m < 1) {
311  KALDI_ERR << "Invalid value --frame-subsampling-factor=" << m;
312  }
313  bool changed = false;
314  for (size_t i = 0; i < num_frames.size(); i++) {
315  int32 value = num_frames[i];
316  if (value <= 0) {
317  KALDI_ERR << "Invalid option --num-frames=" << num_frames_str;
318  }
319  if (value % m != 0) {
320  value = m * ((value / m) + 1);
321  changed = true;
322  }
323  num_frames[i] = value;
324  }
325  if (changed) {
326  std::ostringstream rounded_num_frames_str;
327  for (size_t i = 0; i < num_frames.size(); i++) {
328  if (i > 0)
329  rounded_num_frames_str << ',';
330  rounded_num_frames_str << num_frames[i];
331  }
332  KALDI_LOG << "Rounding up --num-frames=" << num_frames_str
333  << " to multiples of --frame-subsampling-factor=" << m
334  << ", to: " << rounded_num_frames_str.str();
335  }
336 }
bool SplitStringToIntegers(const std::string &full, const char *delim, bool omit_empty_strings, std::vector< I > *out)
Split a string (e.g.
Definition: text-utils.h:68
#define KALDI_ERR
Definition: kaldi-error.h:127
#define KALDI_LOG
Definition: kaldi-error.h:133
void Register ( OptionsItf po)
inline

Definition at line 110 of file nnet-example-utils.h.

References OptionsItf::Register().

Referenced by main().

110  {
111  po->Register("left-context", &left_context, "Number of frames of left "
112  "context of input features that are added to each "
113  "example");
114  po->Register("right-context", &right_context, "Number of frames of right "
115  "context of input features that are added to each "
116  "example");
117  po->Register("left-context-initial", &left_context_initial, "Number of "
118  "frames of left context of input features that are added to "
119  "each example at the start of the utterance (if <0, this "
120  "defaults to the same as --left-context)");
121  po->Register("right-context-final", &right_context_final, "Number of "
122  "frames of right context of input features that are added "
123  "to each example at the end of the utterance (if <0, this "
124  "defaults to the same as --right-context)");
125  po->Register("num-frames", &num_frames_str, "Number of frames with labels "
126  "that each example contains (i.e. the left and right context "
127  "are to be added to this). May just be an integer (e.g. "
128  "--num-frames=8), or a principal value followed by "
129  "alternative values to be used at most once for each utterance "
130  "to deal with odd-sized input, e.g. --num-frames=40,25,50 means "
131  "that most of the time the number of frames will be 40, but to "
132  "deal with odd-sized inputs we may also generate egs with these "
133  "other sizes. All these values will be rounded up to the "
134  "closest multiple of --frame-subsampling-factor.");
135  po->Register("num-frames-overlap", &num_frames_overlap, "Number of frames of "
136  "overlap between adjacent eamples (applies to chunks of size "
137  "equal to the primary [first-listed] --num-frames value... "
138  "will be adjusted for different-sized chunks). Advisory; "
139  "will not be exactly enforced.");
140  po->Register("frame-subsampling-factor", &frame_subsampling_factor, "Used "
141  "if the frame-rate of the output labels in the generated "
142  "examples will be less than the frame-rate at the input");
143  }

Member Data Documentation

int32 left_context

Definition at line 83 of file nnet-example-utils.h.

Referenced by UtteranceSplitter::GetChunksForUtterance().

int32 left_context_initial

Definition at line 85 of file nnet-example-utils.h.

Referenced by UtteranceSplitter::GetChunksForUtterance().

int32 num_frames_overlap
std::string num_frames_str

Definition at line 89 of file nnet-example-utils.h.

Referenced by ExampleGenerationConfig::ComputeDerived().

int32 right_context

Definition at line 84 of file nnet-example-utils.h.

Referenced by UtteranceSplitter::GetChunksForUtterance().

int32 right_context_final

Definition at line 86 of file nnet-example-utils.h.

Referenced by UtteranceSplitter::GetChunksForUtterance().


The documentation for this struct was generated from the following files: