NnetChainExample Struct Reference

NnetChainExample is like NnetExample, but specialized for lattice-free (chain) training. More...

#include <nnet-chain-example.h>

Collaboration diagram for NnetChainExample:

Public Member Functions

void Write (std::ostream &os, bool binary) const
 
void Read (std::istream &is, bool binary)
 
void Swap (NnetChainExample *other)
 
void Compress ()
 
 NnetChainExample ()
 
 NnetChainExample (const NnetChainExample &other)
 
bool operator== (const NnetChainExample &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< NnetChainSupervisionoutputs
 'outputs' contains the chain output supervision. More...
 

Detailed Description

NnetChainExample is like NnetExample, but specialized for lattice-free (chain) training.

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

Constructor & Destructor Documentation

◆ NnetChainExample() [1/2]

NnetChainExample ( )
inline

Definition at line 129 of file nnet-chain-example.h.

129 { }

◆ NnetChainExample() [2/2]

NnetChainExample ( const NnetChainExample other)

Definition at line 189 of file nnet-chain-example.cc.

189  :
190  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< NnetChainSupervision > outputs
&#39;outputs&#39; contains the chain output supervision.

Member Function Documentation

◆ Compress()

void Compress ( )

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

182  {
183  std::vector<NnetIo>::iterator iter = inputs.begin(), end = inputs.end();
184  // calling features.Compress() will do nothing if they are sparse or already
185  // compressed.
186  for (; iter != end; ++iter) iter->features.Compress();
187 }
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 NnetChainExample other) const
inline

Definition at line 133 of file nnet-chain-example.h.

References NnetChainExample::inputs, and NnetChainExample::outputs.

133  {
134  return inputs == other.inputs && outputs == other.outputs;
135  }
std::vector< NnetIo > inputs
&#39;inputs&#39; contains the input to the network– normally just it has just one element called "input"...
std::vector< NnetChainSupervision > outputs
&#39;outputs&#39; contains the chain output supervision.

◆ Read()

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

Definition at line 157 of file nnet-chain-example.cc.

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

157  {
158  ExpectToken(is, binary, "<Nnet3ChainEg>");
159  ExpectToken(is, binary, "<NumInputs>");
160  int32 size;
161  ReadBasicType(is, binary, &size);
162  if (size < 1 || size > 1000000)
163  KALDI_ERR << "Invalid size " << size;
164  inputs.resize(size);
165  for (int32 i = 0; i < size; i++)
166  inputs[i].Read(is, binary);
167  ExpectToken(is, binary, "<NumOutputs>");
168  ReadBasicType(is, binary, &size);
169  if (size < 1 || size > 1000000)
170  KALDI_ERR << "Invalid size " << size;
171  outputs.resize(size);
172  for (int32 i = 0; i < size; i++)
173  outputs[i].Read(is, binary);
174  ExpectToken(is, binary, "</Nnet3ChainEg>");
175 }
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
std::vector< NnetIo > inputs
&#39;inputs&#39; contains the input to the network– normally just it has just one element called "input"...
kaldi::int32 int32
static void ExpectToken(const std::string &token, const std::string &what_we_are_parsing, const std::string **next_token)
std::vector< NnetChainSupervision > outputs
&#39;outputs&#39; contains the chain output supervision.
#define KALDI_ERR
Definition: kaldi-error.h:147
void Read(std::istream &is, bool binary)

◆ Swap()

void Swap ( NnetChainExample other)

Definition at line 177 of file nnet-chain-example.cc.

References NnetChainExample::inputs, and NnetChainExample::outputs.

177  {
178  inputs.swap(other->inputs);
179  outputs.swap(other->outputs);
180 }
std::vector< NnetIo > inputs
&#39;inputs&#39; contains the input to the network– normally just it has just one element called "input"...
std::vector< NnetChainSupervision > outputs
&#39;outputs&#39; contains the chain output supervision.

◆ Write()

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

Definition at line 132 of file nnet-chain-example.cc.

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

132  {
133  // Note: weight, label, input_frames and spk_info are members. This is a
134  // struct.
135  WriteToken(os, binary, "<Nnet3ChainEg>");
136  WriteToken(os, binary, "<NumInputs>");
137  int32 size = inputs.size();
138  WriteBasicType(os, binary, size);
139  KALDI_ASSERT(size > 0 && "Attempting to write NnetChainExample with no inputs");
140  if (!binary) os << '\n';
141  for (int32 i = 0; i < size; i++) {
142  inputs[i].Write(os, binary);
143  if (!binary) os << '\n';
144  }
145  WriteToken(os, binary, "<NumOutputs>");
146  size = outputs.size();
147  WriteBasicType(os, binary, size);
148  KALDI_ASSERT(size > 0 && "Attempting to write NnetChainExample with no outputs");
149  if (!binary) os << '\n';
150  for (int32 i = 0; i < size; i++) {
151  outputs[i].Write(os, binary);
152  if (!binary) os << '\n';
153  }
154  WriteToken(os, binary, "</Nnet3ChainEg>");
155 }
std::vector< NnetIo > inputs
&#39;inputs&#39; contains the input to the network– normally just it has just one element called "input"...
kaldi::int32 int32
std::vector< NnetChainSupervision > outputs
&#39;outputs&#39; contains the chain output supervision.
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
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

std::vector<NnetIo> inputs

◆ outputs


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