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< int32num_frames
 

Detailed Description

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

Constructor & Destructor Documentation

◆ ExampleGenerationConfig()

Member Function Documentation

◆ ComputeDerived()

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 ExampleGenerationConfig::ExampleGenerationConfig(), main(), and ExampleMergingConfig::Register().

302  {
303  if (num_frames_str == "-1") {
304  return;
305  }
306  if (!SplitStringToIntegers(num_frames_str, ",", false, &num_frames) ||
307  num_frames.empty()) {
308  KALDI_ERR << "Invalid option (expected comma-separated list of integers): "
309  << "--num-frames=" << num_frames_str;
310  }
311 
313  if (m < 1) {
314  KALDI_ERR << "Invalid value --frame-subsampling-factor=" << m;
315  }
316  bool changed = false;
317  for (size_t i = 0; i < num_frames.size(); i++) {
318  int32 value = num_frames[i];
319  if (value <= 0) {
320  KALDI_ERR << "Invalid option --num-frames=" << num_frames_str;
321  }
322  if (value % m != 0) {
323  value = m * ((value / m) + 1);
324  changed = true;
325  }
326  num_frames[i] = value;
327  }
328  if (changed) {
329  std::ostringstream rounded_num_frames_str;
330  for (size_t i = 0; i < num_frames.size(); i++) {
331  if (i > 0)
332  rounded_num_frames_str << ',';
333  rounded_num_frames_str << num_frames[i];
334  }
335  KALDI_LOG << "Rounding up --num-frames=" << num_frames_str
336  << " to multiples of --frame-subsampling-factor=" << m
337  << ", to: " << rounded_num_frames_str.str();
338  }
339 }
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
kaldi::int32 int32
#define KALDI_ERR
Definition: kaldi-error.h:147
#define KALDI_LOG
Definition: kaldi-error.h:153

◆ Register()

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. As a special case, "
135  "--num-frames=-1 means 'don't do any splitting'.");
136  po->Register("num-frames-overlap", &num_frames_overlap, "Number of frames of "
137  "overlap between adjacent eamples (applies to chunks of size "
138  "equal to the primary [first-listed] --num-frames value... "
139  "will be adjusted for different-sized chunks). Advisory; "
140  "will not be exactly enforced.");
141  po->Register("frame-subsampling-factor", &frame_subsampling_factor, "Used "
142  "if the frame-rate of the output labels in the generated "
143  "examples will be less than the frame-rate at the input");
144  }

Member Data Documentation

◆ frame_subsampling_factor

◆ left_context

int32 left_context

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

Referenced by UtteranceSplitter::GetChunksForUtterance().

◆ left_context_initial

int32 left_context_initial

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

Referenced by UtteranceSplitter::GetChunksForUtterance().

◆ num_frames

◆ num_frames_overlap

◆ num_frames_str

◆ right_context

int32 right_context

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

Referenced by UtteranceSplitter::GetChunksForUtterance().

◆ right_context_final

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: