NnetExample is the input data and corresponding label (or labels) for one or more frames of input, used for standard cross-entropy training of neural nets (and possibly for other objective functions). More...
#include <nnet-example.h>
Public Member Functions | |
void | Write (std::ostream &os, bool binary) const |
void | Read (std::istream &is, bool binary) |
NnetExample () | |
NnetExample (const NnetExample &input, int32 start_frame, int32 num_frames, int32 left_context, int32 right_context) | |
This constructor can be used to extract one or more frames from an example that has multiple frames, and possibly truncate the context. More... | |
void | SetLabelSingle (int32 frame, int32 pdf_id, BaseFloat weight=1.0) |
Set the label of this frame of this example to the specified pdf_id with the specified weight. More... | |
int32 | GetLabelSingle (int32 frame, BaseFloat *weight=NULL) |
Get the maximum weight label (pdf_id and weight) of this frame of this example. More... | |
Public Attributes | |
std::vector< std::vector< std::pair< int32, BaseFloat > > > | labels |
The label(s) for each frame in a sequence of frames; in the normal case, this will be just [ [ (pdf-id, 1.0) ] ], i.e. More... | |
CompressedMatrix | input_frames |
The input data, with NumRows() >= labels.size() + left_context; it includes features to the left and right as needed for the temporal context of the network. More... | |
int32 | left_context |
The number of frames of left context (we can work out the #frames of right context from input_frames.NumRows(), labels.size(), and this). More... | |
Vector< BaseFloat > | spk_info |
The speaker-specific input, if any, or an empty vector if we're not using this features. More... | |
NnetExample is the input data and corresponding label (or labels) for one or more frames of input, used for standard cross-entropy training of neural nets (and possibly for other objective functions).
In the normal case there will be just one frame, and one label, with a weight of 1.0.
Definition at line 36 of file nnet-example.h.
|
inline |
Definition at line 63 of file nnet-example.h.
References NnetExample::GetLabelSingle(), and NnetExample::SetLabelSingle().
NnetExample | ( | const NnetExample & | input, |
int32 | start_frame, | ||
int32 | num_frames, | ||
int32 | left_context, | ||
int32 | right_context | ||
) |
This constructor can be used to extract one or more frames from an example that has multiple frames, and possibly truncate the context.
Most of its behavior is obvious from the variable names, but note the following: if left_context is -1, we use the left-context of the input; the same for right_context. If start_frame < 0 we start the labels from frame 0 of the labeled frames of ,input; if num_frames == -1 we go to the end of the labeled input from start_frame. If start_frame + num_frames is greater than the number of frames of labels of input, we output as much as we can instead of crashing. The same with left_context and right_context– if we can't provide the requested context we won't crash but will provide as much as we can, although in this case we'll print a warning (once).
Definition at line 159 of file nnet-example.cc.
References NnetExample::input_frames, KALDI_ASSERT, KALDI_WARN, NnetExample::labels, NnetExample::left_context, kaldi::nnet2::nnet_example_warned_right, CompressedMatrix::NumCols(), CompressedMatrix::NumRows(), and CompressedMatrix::Swap().
Get the maximum weight label (pdf_id and weight) of this frame of this example.
Definition at line 140 of file nnet-example.cc.
References rnnlm::i, KALDI_ASSERT, and NnetExample::labels.
Referenced by NnetExample::NnetExample().
void Read | ( | std::istream & | is, |
bool | binary | ||
) |
Definition at line 80 of file nnet-example.cc.
References kaldi::ExpectToken(), rnnlm::i, NnetExample::input_frames, KALDI_ASSERT, KALDI_ERR, NnetExample::labels, NnetExample::left_context, CompressedMatrix::Read(), kaldi::ReadBasicType(), kaldi::ReadIntegerVector(), kaldi::ReadToken(), and NnetExample::spk_info.
Set the label of this frame of this example to the specified pdf_id with the specified weight.
Definition at line 134 of file nnet-example.cc.
References KALDI_ASSERT, and NnetExample::labels.
Referenced by NnetExample::NnetExample().
void Write | ( | std::ostream & | os, |
bool | binary | ||
) | const |
Definition at line 46 of file nnet-example.cc.
References kaldi::nnet2::HasSimpleLabels(), rnnlm::i, NnetExample::input_frames, NnetExample::labels, NnetExample::left_context, NnetExample::spk_info, CompressedMatrix::Write(), kaldi::WriteBasicType(), kaldi::WriteIntegerVector(), and kaldi::WriteToken().
CompressedMatrix input_frames |
The input data, with NumRows() >= labels.size() + left_context; it includes features to the left and right as needed for the temporal context of the network.
The features corresponding to labels[0] would be in the row with index equal to left_context.
Definition at line 49 of file nnet-example.h.
Referenced by DiscriminativeNnetExample::Check(), main(), NnetExample::NnetExample(), kaldi::nnet2::ProcessFile(), NnetExample::Read(), DiscriminativeNnetExample::Read(), NnetExample::Write(), and DiscriminativeNnetExample::Write().
The label(s) for each frame in a sequence of frames; in the normal case, this will be just [ [ (pdf-id, 1.0) ] ], i.e.
one frame with one label. Top-level index is the frame index; then for each frame, a list of pdf-ids each with its weight. In some contexts, we will require that labels.size() == 1.
Definition at line 43 of file nnet-example.h.
Referenced by NnetExample::GetLabelSingle(), kaldi::nnet2::HasSimpleLabels(), main(), NnetExample::NnetExample(), kaldi::nnet2::ProcessFile(), NnetExample::Read(), NnetExample::SetLabelSingle(), and NnetExample::Write().
int32 left_context |
The number of frames of left context (we can work out the #frames of right context from input_frames.NumRows(), labels.size(), and this).
Definition at line 53 of file nnet-example.h.
Referenced by DiscriminativeNnetExample::Check(), main(), NnetExample::NnetExample(), kaldi::nnet2::ProcessFile(), NnetExample::Read(), DiscriminativeNnetExample::Read(), NnetExample::Write(), and DiscriminativeNnetExample::Write().
The speaker-specific input, if any, or an empty vector if we're not using this features.
We'll append this to the features for each of the frames.
Definition at line 58 of file nnet-example.h.
Referenced by main(), kaldi::nnet2::ProcessFile(), NnetExample::Read(), DiscriminativeNnetExample::Read(), NnetExample::Write(), and DiscriminativeNnetExample::Write().