This Decodable object for class nnet2::AmNnet takes feature input from class OnlineFeatureInterface, unlike, say, class DecodableAmNnet which takes feature input from a matrix. More...
#include <online-nnet2-decodable.h>
Public Member Functions | |
DecodableNnet2Online (const AmNnet &nnet, const TransitionModel &trans_model, const DecodableNnet2OnlineOptions &opts, OnlineFeatureInterface *input_feats) | |
virtual BaseFloat | LogLikelihood (int32 frame, int32 index) |
Returns the scaled log likelihood. More... | |
virtual bool | IsLastFrame (int32 frame) const |
Returns true if this is the last frame. More... | |
virtual int32 | NumFramesReady () const |
The call NumFramesReady() will return the number of frames currently available for this decodable object. More... | |
virtual int32 | NumIndices () const |
Indices are one-based! This is for compatibility with OpenFst. More... | |
Public Member Functions inherited from DecodableInterface | |
virtual | ~DecodableInterface () |
Private Member Functions | |
void | ComputeForFrame (int32 frame) |
If the neural-network outputs for this frame are not cached, it computes them (and possibly for some succeeding frames) More... | |
KALDI_DISALLOW_COPY_AND_ASSIGN (DecodableNnet2Online) | |
Private Attributes | |
OnlineFeatureInterface * | features_ |
const AmNnet & | nnet_ |
const TransitionModel & | trans_model_ |
DecodableNnet2OnlineOptions | opts_ |
CuVector< BaseFloat > | log_priors_ |
int32 | feat_dim_ |
int32 | left_context_ |
int32 | right_context_ |
int32 | num_pdfs_ |
int32 | begin_frame_ |
Matrix< BaseFloat > | scaled_loglikes_ |
This Decodable object for class nnet2::AmNnet takes feature input from class OnlineFeatureInterface, unlike, say, class DecodableAmNnet which takes feature input from a matrix.
Definition at line 68 of file online-nnet2-decodable.h.
DecodableNnet2Online | ( | const AmNnet & | nnet, |
const TransitionModel & | trans_model, | ||
const DecodableNnet2OnlineOptions & | opts, | ||
OnlineFeatureInterface * | input_feats | ||
) |
Definition at line 25 of file online-nnet2-decodable.cc.
References KALDI_ASSERT, DecodableNnet2Online::log_priors_, DecodableNnet2OnlineOptions::max_nnet_batch_size, DecodableNnet2Online::nnet_, TransitionModel::NumPdfs(), DecodableNnet2Online::opts_, AmNnet::Priors(), and DecodableNnet2Online::trans_model_.
|
private |
If the neural-network outputs for this frame are not cached, it computes them (and possibly for some succeeding frames)
Definition at line 81 of file online-nnet2-decodable.cc.
References DecodableNnet2OnlineOptions::acoustic_scale, CuMatrixBase< Real >::AddVecToRows(), CuMatrixBase< Real >::ApplyFloor(), CuMatrixBase< Real >::ApplyLog(), DecodableNnet2Online::begin_frame_, DecodableNnet2Online::feat_dim_, DecodableNnet2Online::features_, OnlineFeatureInterface::GetFrame(), AmNnet::GetNnet(), OnlineFeatureInterface::IsLastFrame(), KALDI_ASSERT, DecodableNnet2Online::left_context_, DecodableNnet2Online::log_priors_, DecodableNnet2OnlineOptions::max_nnet_batch_size, DecodableNnet2Online::nnet_, kaldi::nnet2::NnetComputation(), DecodableNnet2Online::num_pdfs_, OnlineFeatureInterface::NumFramesReady(), DecodableNnet2Online::NumFramesReady(), MatrixBase< Real >::NumRows(), DecodableNnet2Online::opts_, DecodableNnet2OnlineOptions::pad_input, Matrix< Real >::Resize(), DecodableNnet2Online::right_context_, CuMatrixBase< Real >::Scale(), DecodableNnet2Online::scaled_loglikes_, and CuMatrix< Real >::Swap().
Referenced by DecodableNnet2Online::LogLikelihood().
Returns true if this is the last frame.
Frames are zero-based, so the first frame is zero. IsLastFrame(-1) will return false, unless the file is empty (which is a case that I'm not sure all the code will handle, so be careful). Caution: the behavior of this function in an online setting is being changed somewhat. In future it may return false in cases where we haven't yet decided to terminate decoding, but later true if we decide to terminate decoding. The plan in future is to rely more on NumFramesReady(), and in future, IsLastFrame() would always return false in an online-decoding setting, and would only return true in a decoding-from-matrix setting where we want to allow the last delta or LDA features to be flushed out for compatibility with the baseline setup.
Implements DecodableInterface.
Definition at line 58 of file online-nnet2-decodable.cc.
References DecodableNnet2Online::features_, OnlineFeatureInterface::IsLastFrame(), DecodableNnet2Online::left_context_, DecodableNnet2Online::opts_, DecodableNnet2OnlineOptions::pad_input, and DecodableNnet2Online::right_context_.
|
private |
Returns the scaled log likelihood.
Implements DecodableInterface.
Definition at line 49 of file online-nnet2-decodable.cc.
References DecodableNnet2Online::begin_frame_, DecodableNnet2Online::ComputeForFrame(), KALDI_ASSERT, MatrixBase< Real >::NumRows(), DecodableNnet2Online::scaled_loglikes_, DecodableNnet2Online::trans_model_, and TransitionModel::TransitionIdToPdf().
Referenced by kaldi::nnet2::UnitTestNnetDecodable().
|
virtual |
The call NumFramesReady() will return the number of frames currently available for this decodable object.
This is for use in setups where you don't want the decoder to block while waiting for input. This is newly added as of Jan 2014, and I hope, going forward, to rely on this mechanism more than IsLastFrame to know when to stop decoding.
Reimplemented from DecodableInterface.
Definition at line 66 of file online-nnet2-decodable.cc.
References DecodableNnet2Online::features_, OnlineFeatureInterface::IsLastFrame(), DecodableNnet2Online::left_context_, OnlineFeatureInterface::NumFramesReady(), DecodableNnet2Online::opts_, DecodableNnet2OnlineOptions::pad_input, and DecodableNnet2Online::right_context_.
Referenced by DecodableNnet2Online::ComputeForFrame(), and kaldi::nnet2::UnitTestNnetDecodable().
|
inlinevirtual |
Indices are one-based! This is for compatibility with OpenFst.
Implements DecodableInterface.
Definition at line 84 of file online-nnet2-decodable.h.
|
private |
Definition at line 103 of file online-nnet2-decodable.h.
Referenced by DecodableNnet2Online::ComputeForFrame(), and DecodableNnet2Online::LogLikelihood().
|
private |
Definition at line 97 of file online-nnet2-decodable.h.
Referenced by DecodableNnet2Online::ComputeForFrame().
|
private |
Definition at line 92 of file online-nnet2-decodable.h.
Referenced by DecodableNnet2Online::ComputeForFrame(), DecodableNnet2Online::IsLastFrame(), and DecodableNnet2Online::NumFramesReady().
|
private |
Definition at line 98 of file online-nnet2-decodable.h.
Referenced by DecodableNnet2Online::ComputeForFrame(), DecodableNnet2Online::IsLastFrame(), and DecodableNnet2Online::NumFramesReady().
Definition at line 96 of file online-nnet2-decodable.h.
Referenced by DecodableNnet2Online::ComputeForFrame(), and DecodableNnet2Online::DecodableNnet2Online().
|
private |
Definition at line 93 of file online-nnet2-decodable.h.
Referenced by DecodableNnet2Online::ComputeForFrame(), and DecodableNnet2Online::DecodableNnet2Online().
|
private |
Definition at line 100 of file online-nnet2-decodable.h.
Referenced by DecodableNnet2Online::ComputeForFrame().
|
private |
Definition at line 95 of file online-nnet2-decodable.h.
Referenced by DecodableNnet2Online::ComputeForFrame(), DecodableNnet2Online::DecodableNnet2Online(), DecodableNnet2Online::IsLastFrame(), and DecodableNnet2Online::NumFramesReady().
|
private |
Definition at line 99 of file online-nnet2-decodable.h.
Referenced by DecodableNnet2Online::ComputeForFrame(), DecodableNnet2Online::IsLastFrame(), and DecodableNnet2Online::NumFramesReady().
Definition at line 114 of file online-nnet2-decodable.h.
Referenced by DecodableNnet2Online::ComputeForFrame(), and DecodableNnet2Online::LogLikelihood().
|
private |
Definition at line 94 of file online-nnet2-decodable.h.
Referenced by DecodableNnet2Online::DecodableNnet2Online(), and DecodableNnet2Online::LogLikelihood().