#include <decodable-online-looped.h>
Public Member Functions | |
DecodableNnetLoopedOnlineBase (const DecodableNnetSimpleLoopedInfo &info, OnlineFeatureInterface *input_features, OnlineFeatureInterface *ivector_features) | |
virtual bool | IsLastFrame (int32 subsampled_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... | |
int32 | FrameSubsamplingFactor () const |
void | SetFrameOffset (int32 frame_offset) |
Sets the frame offset value. More... | |
int32 | GetFrameOffset () const |
Returns the frame offset value. More... | |
Public Member Functions inherited from DecodableInterface | |
virtual BaseFloat | LogLikelihood (int32 frame, int32 index)=0 |
Returns the log likelihood, which will be negated in the decoder. More... | |
virtual int32 | NumIndices () const =0 |
Returns the number of states in the acoustic model (they will be indexed one-based, i.e. More... | |
virtual | ~DecodableInterface () |
Protected Member Functions | |
void | EnsureFrameIsComputed (int32 subsampled_frame) |
If the neural-network outputs for this frame are not cached, this function computes them (and possibly also some later frames). More... | |
Protected Attributes | |
Matrix< BaseFloat > | current_log_post_ |
int32 | num_chunks_computed_ |
int32 | current_log_post_subsampled_offset_ |
const DecodableNnetSimpleLoopedInfo & | info_ |
int32 | frame_offset_ |
Private Member Functions | |
void | AdvanceChunk () |
KALDI_DISALLOW_COPY_AND_ASSIGN (DecodableNnetLoopedOnlineBase) | |
Private Attributes | |
OnlineFeatureInterface * | input_features_ |
OnlineFeatureInterface * | ivector_features_ |
NnetComputer | computer_ |
Definition at line 56 of file decodable-online-looped.h.
DecodableNnetLoopedOnlineBase | ( | const DecodableNnetSimpleLoopedInfo & | info, |
OnlineFeatureInterface * | input_features, | ||
OnlineFeatureInterface * | ivector_features | ||
) |
Definition at line 26 of file decodable-online-looped.cc.
References OnlineFeatureInterface::Dim(), DecodableNnetLoopedOnlineBase::info_, DecodableNnetLoopedOnlineBase::input_features_, Nnet::InputDim(), DecodableNnetLoopedOnlineBase::ivector_features_, KALDI_ASSERT, KALDI_ERR, and DecodableNnetSimpleLoopedInfo::nnet.
|
private |
Definition at line 118 of file decodable-online-looped.cc.
References NnetComputer::AcceptInput(), NnetSimpleLoopedComputationOptions::acoustic_scale, CuMatrixBase< Real >::AddVecToRows(), DecodableNnetLoopedOnlineBase::computer_, MatrixBase< Real >::CopyRowsFromVec(), DecodableNnetLoopedOnlineBase::current_log_post_, DecodableNnetLoopedOnlineBase::current_log_post_subsampled_offset_, OnlineFeatureInterface::Dim(), NnetSimpleLoopedComputationOptions::frame_subsampling_factor, DecodableNnetSimpleLoopedInfo::frames_left_context, DecodableNnetSimpleLoopedInfo::frames_per_chunk, DecodableNnetSimpleLoopedInfo::frames_right_context, OnlineFeatureInterface::GetFrame(), NnetComputer::GetOutputDestructive(), DecodableNnetSimpleLoopedInfo::has_ivectors, rnnlm::i, DecodableNnetLoopedOnlineBase::info_, DecodableNnetLoopedOnlineBase::input_features_, ComputationRequest::inputs, OnlineFeatureInterface::IsLastFrame(), DecodableNnetLoopedOnlineBase::ivector_features_, KALDI_ASSERT, KALDI_ERR, DecodableNnetSimpleLoopedInfo::log_priors, DecodableNnetLoopedOnlineBase::num_chunks_computed_, MatrixBase< Real >::NumCols(), OnlineFeatureInterface::NumFramesReady(), MatrixBase< Real >::NumRows(), DecodableNnetSimpleLoopedInfo::opts, DecodableNnetSimpleLoopedInfo::output_dim, DecodableNnetSimpleLoopedInfo::request1, DecodableNnetSimpleLoopedInfo::request2, Matrix< Real >::Resize(), NnetComputer::Run(), CuMatrixBase< Real >::Scale(), Matrix< Real >::Swap(), and CuMatrix< Real >::Swap().
Referenced by DecodableNnetLoopedOnlineBase::EnsureFrameIsComputed().
|
inlineprotected |
If the neural-network outputs for this frame are not cached, this function computes them (and possibly also some later frames).
Note: the frame-index is called 'subsampled_frame' because if frame-subsampling-factor is not 1, it's an index that is "after subsampling", i.e. it changes more slowly than the input-feature index.
Definition at line 103 of file decodable-online-looped.h.
References DecodableNnetLoopedOnlineBase::AdvanceChunk(), DecodableNnetLoopedOnlineBase::current_log_post_, DecodableNnetLoopedOnlineBase::current_log_post_subsampled_offset_, KALDI_ASSERT, and MatrixBase< Real >::NumRows().
Referenced by DecodableNnetLoopedOnline::LogLikelihood(), and DecodableAmNnetLoopedOnline::LogLikelihood().
|
inline |
Definition at line 80 of file decodable-online-looped.h.
References NnetSimpleLoopedComputationOptions::frame_subsampling_factor, DecodableNnetLoopedOnlineBase::info_, DecodableNnetSimpleLoopedInfo::opts, and DecodableNnetLoopedOnlineBase::SetFrameOffset().
Referenced by SingleUtteranceNnet3DecoderTpl< FST >::EndpointDetected(), and SingleUtteranceNnet3IncrementalDecoderTpl< FST >::EndpointDetected().
|
inline |
Returns the frame offset value.
Definition at line 94 of file decodable-online-looped.h.
References DecodableNnetLoopedOnlineBase::frame_offset_.
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 89 of file decodable-online-looped.cc.
References DecodableNnetLoopedOnlineBase::frame_offset_, NnetSimpleLoopedComputationOptions::frame_subsampling_factor, DecodableNnetLoopedOnlineBase::info_, DecodableNnetLoopedOnlineBase::input_features_, OnlineFeatureInterface::IsLastFrame(), OnlineFeatureInterface::NumFramesReady(), and DecodableNnetSimpleLoopedInfo::opts.
|
private |
Referenced by DecodableNnetLoopedOnline::NumIndices().
|
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 56 of file decodable-online-looped.cc.
References DecodableNnetLoopedOnlineBase::frame_offset_, NnetSimpleLoopedComputationOptions::frame_subsampling_factor, DecodableNnetSimpleLoopedInfo::frames_per_chunk, DecodableNnetSimpleLoopedInfo::frames_right_context, DecodableNnetLoopedOnlineBase::info_, DecodableNnetLoopedOnlineBase::input_features_, OnlineFeatureInterface::IsLastFrame(), OnlineFeatureInterface::NumFramesReady(), and DecodableNnetSimpleLoopedInfo::opts.
Referenced by DecodableNnetLoopedOnlineBase::SetFrameOffset().
void SetFrameOffset | ( | int32 | frame_offset | ) |
Sets the frame offset value.
Frame offset is initialized to 0 when the decodable object is constructed and stays as 0 unless this method is called. This method is useful when we want to reset the decoder state, i.e. call decoder.InitDecoding(), but we want to keep using the same decodable object, e.g. in case of an endpoint. The frame offset affects the behavior of IsLastFrame(), NumFramesReady() and LogLikelihood() methods.
Definition at line 112 of file decodable-online-looped.cc.
References DecodableNnetLoopedOnlineBase::frame_offset_, KALDI_ASSERT, and DecodableNnetLoopedOnlineBase::NumFramesReady().
Referenced by DecodableNnetLoopedOnlineBase::FrameSubsamplingFactor(), SingleUtteranceNnet3IncrementalDecoderTpl< FST >::InitDecoding(), and SingleUtteranceNnet3DecoderTpl< FST >::InitDecoding().
|
private |
Definition at line 140 of file decodable-online-looped.h.
Referenced by DecodableNnetLoopedOnlineBase::AdvanceChunk().
Definition at line 113 of file decodable-online-looped.h.
Referenced by DecodableNnetLoopedOnlineBase::AdvanceChunk(), DecodableNnetLoopedOnlineBase::EnsureFrameIsComputed(), DecodableNnetLoopedOnline::LogLikelihood(), and DecodableAmNnetLoopedOnline::LogLikelihood().
|
protected |
Definition at line 121 of file decodable-online-looped.h.
Referenced by DecodableNnetLoopedOnlineBase::AdvanceChunk(), DecodableNnetLoopedOnlineBase::EnsureFrameIsComputed(), DecodableNnetLoopedOnline::LogLikelihood(), and DecodableAmNnetLoopedOnline::LogLikelihood().
|
protected |
Definition at line 128 of file decodable-online-looped.h.
Referenced by DecodableNnetLoopedOnlineBase::GetFrameOffset(), DecodableNnetLoopedOnlineBase::IsLastFrame(), DecodableNnetLoopedOnline::LogLikelihood(), DecodableAmNnetLoopedOnline::LogLikelihood(), DecodableNnetLoopedOnlineBase::NumFramesReady(), and DecodableNnetLoopedOnlineBase::SetFrameOffset().
|
protected |
Definition at line 123 of file decodable-online-looped.h.
Referenced by DecodableNnetLoopedOnlineBase::AdvanceChunk(), DecodableNnetLoopedOnlineBase::DecodableNnetLoopedOnlineBase(), DecodableNnetLoopedOnlineBase::FrameSubsamplingFactor(), DecodableNnetLoopedOnlineBase::IsLastFrame(), DecodableNnetLoopedOnlineBase::NumFramesReady(), and DecodableNnetLoopedOnline::NumIndices().
|
private |
|
private |
Definition at line 138 of file decodable-online-looped.h.
Referenced by DecodableNnetLoopedOnlineBase::AdvanceChunk(), and DecodableNnetLoopedOnlineBase::DecodableNnetLoopedOnlineBase().
|
protected |
Definition at line 116 of file decodable-online-looped.h.
Referenced by DecodableNnetLoopedOnlineBase::AdvanceChunk().