NnetDiscriminativeExample Struct Reference

NnetDiscriminativeExample is like NnetExample, but specialized for sequence training. More...

#include <nnet-discriminative-example.h>

Collaboration diagram for NnetDiscriminativeExample:

Public Member Functions

void Write (std::ostream &os, bool binary) const
 
void Read (std::istream &is, bool binary)
 
void Swap (NnetDiscriminativeExample *other)
 
void Compress ()
 
 NnetDiscriminativeExample ()
 
 NnetDiscriminativeExample (const NnetDiscriminativeExample &other)
 
bool operator== (const NnetDiscriminativeExample &other) const
 

Public Attributes

std::vector< NnetIoinputs
 'inputs' contains the input to the network– normally just it has just one element called "input", but there may be others (e.g. More...
 
std::vector< NnetDiscriminativeSupervisionoutputs
 'outputs' contains the sequence output supervision. More...
 

Detailed Description

NnetDiscriminativeExample is like NnetExample, but specialized for sequence training.

Definition at line 103 of file nnet-discriminative-example.h.

Constructor & Destructor Documentation

◆ NnetDiscriminativeExample() [1/2]

Definition at line 123 of file nnet-discriminative-example.h.

123 { }

◆ NnetDiscriminativeExample() [2/2]

Definition at line 182 of file nnet-discriminative-example.cc.

182  :
183  inputs(other.inputs), outputs(other.outputs) { }
std::vector< NnetIo > inputs
&#39;inputs&#39; contains the input to the network– normally just it has just one element called "input"...
std::vector< NnetDiscriminativeSupervision > outputs
&#39;outputs&#39; contains the sequence output supervision.

Member Function Documentation

◆ Compress()

void Compress ( )

Definition at line 175 of file nnet-discriminative-example.cc.

Referenced by kaldi::nnet3::ProcessFile().

175  {
176  std::vector<NnetIo>::iterator iter = inputs.begin(), end = inputs.end();
177  // calling features.Compress() will do nothing if they are sparse or already
178  // compressed.
179  for (; iter != end; ++iter) iter->features.Compress();
180 }
std::vector< NnetIo > inputs
&#39;inputs&#39; contains the input to the network– normally just it has just one element called "input"...

◆ operator==()

bool operator== ( const NnetDiscriminativeExample other) const
inline

Definition at line 127 of file nnet-discriminative-example.h.

References NnetDiscriminativeExample::inputs, and NnetDiscriminativeExample::outputs.

127  {
128  return inputs == other.inputs && outputs == other.outputs;
129  }
std::vector< NnetIo > inputs
&#39;inputs&#39; contains the input to the network– normally just it has just one element called "input"...
std::vector< NnetDiscriminativeSupervision > outputs
&#39;outputs&#39; contains the sequence output supervision.

◆ Read()

void Read ( std::istream &  is,
bool  binary 
)

Definition at line 150 of file nnet-discriminative-example.cc.

References kaldi::nnet3::ExpectToken(), rnnlm::i, KALDI_ERR, NnetDiscriminativeSupervision::Read(), and kaldi::ReadBasicType().

150  {
151  ExpectToken(is, binary, "<Nnet3DiscriminativeEg>");
152  ExpectToken(is, binary, "<NumInputs>");
153  int32 size;
154  ReadBasicType(is, binary, &size);
155  if (size < 1 || size > 1000000)
156  KALDI_ERR << "Invalid size " << size;
157  inputs.resize(size);
158  for (int32 i = 0; i < size; i++)
159  inputs[i].Read(is, binary);
160  ExpectToken(is, binary, "<NumOutputs>");
161  ReadBasicType(is, binary, &size);
162  if (size < 1 || size > 1000000)
163  KALDI_ERR << "Invalid size " << size;
164  outputs.resize(size);
165  for (int32 i = 0; i < size; i++)
166  outputs[i].Read(is, binary);
167  ExpectToken(is, binary, "</Nnet3DiscriminativeEg>");
168 }
void ReadBasicType(std::istream &is, bool binary, T *t)
ReadBasicType is the name of the read function for bool, integer types, and floating-point types...
Definition: io-funcs-inl.h:55
kaldi::int32 int32
static void ExpectToken(const std::string &token, const std::string &what_we_are_parsing, const std::string **next_token)
#define KALDI_ERR
Definition: kaldi-error.h:147
std::vector< NnetIo > inputs
&#39;inputs&#39; contains the input to the network– normally just it has just one element called "input"...
std::vector< NnetDiscriminativeSupervision > outputs
&#39;outputs&#39; contains the sequence output supervision.

◆ Swap()

void Swap ( NnetDiscriminativeExample other)

Definition at line 170 of file nnet-discriminative-example.cc.

References NnetDiscriminativeExample::inputs, and NnetDiscriminativeExample::outputs.

170  {
171  inputs.swap(other->inputs);
172  outputs.swap(other->outputs);
173 }
std::vector< NnetIo > inputs
&#39;inputs&#39; contains the input to the network– normally just it has just one element called "input"...
std::vector< NnetDiscriminativeSupervision > outputs
&#39;outputs&#39; contains the sequence output supervision.

◆ Write()

void Write ( std::ostream &  os,
bool  binary 
) const

Definition at line 125 of file nnet-discriminative-example.cc.

References rnnlm::i, KALDI_ASSERT, kaldi::WriteBasicType(), and kaldi::WriteToken().

125  {
126  // Note: weight, label, input_frames and spk_info are members. This is a
127  // struct.
128  WriteToken(os, binary, "<Nnet3DiscriminativeEg>");
129  WriteToken(os, binary, "<NumInputs>");
130  int32 size = inputs.size();
131  WriteBasicType(os, binary, size);
132  KALDI_ASSERT(size > 0 && "Attempting to write NnetDiscriminativeExample with no inputs");
133  if (!binary) os << '\n';
134  for (int32 i = 0; i < size; i++) {
135  inputs[i].Write(os, binary);
136  if (!binary) os << '\n';
137  }
138  WriteToken(os, binary, "<NumOutputs>");
139  size = outputs.size();
140  WriteBasicType(os, binary, size);
141  KALDI_ASSERT(size > 0 && "Attempting to write NnetDiscriminativeExample with no outputs");
142  if (!binary) os << '\n';
143  for (int32 i = 0; i < size; i++) {
144  outputs[i].Write(os, binary);
145  if (!binary) os << '\n';
146  }
147  WriteToken(os, binary, "</Nnet3DiscriminativeEg>");
148 }
kaldi::int32 int32
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
Definition: io-funcs.cc:134
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
std::vector< NnetIo > inputs
&#39;inputs&#39; contains the input to the network– normally just it has just one element called "input"...
std::vector< NnetDiscriminativeSupervision > outputs
&#39;outputs&#39; contains the sequence output supervision.
void WriteBasicType(std::ostream &os, bool binary, T t)
WriteBasicType is the name of the write function for bool, integer types, and floating-point types...
Definition: io-funcs-inl.h:34

Member Data Documentation

◆ inputs

◆ outputs


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