This is like DecodableMatrixScaledMapped, but it doesn't support an acoustic scale, and it does support a frame offset, whereby you can state that the first row of 'likes' is actually the n'th row of the matrix of available log-likelihoods. More...
#include <decodable-matrix.h>
Public Member Functions | |
DecodableMatrixMapped (const TransitionModel &tm, const MatrixBase< BaseFloat > &likes, int32 frame_offset=0) | |
DecodableMatrixMapped (const TransitionModel &tm, const Matrix< BaseFloat > *likes, int32 frame_offset=0) | |
virtual int32 | NumFramesReady () const |
The call NumFramesReady() will return the number of frames currently available for this decodable object. More... | |
virtual bool | IsLastFrame (int32 frame) const |
Returns true if this is the last frame. More... | |
virtual BaseFloat | LogLikelihood (int32 frame, int32 tid) |
Returns the log likelihood, which will be negated in the decoder. More... | |
virtual int32 | NumIndices () const |
Returns the number of states in the acoustic model (they will be indexed one-based, i.e. More... | |
virtual | ~DecodableMatrixMapped () |
Public Member Functions inherited from DecodableInterface | |
virtual | ~DecodableInterface () |
Private Member Functions | |
KALDI_DISALLOW_COPY_AND_ASSIGN (DecodableMatrixMapped) | |
Private Attributes | |
const TransitionModel & | trans_model_ |
const MatrixBase< BaseFloat > * | likes_ |
const Matrix< BaseFloat > * | likes_to_delete_ |
int32 | frame_offset_ |
const BaseFloat * | raw_data_ |
int32 | stride_ |
This is like DecodableMatrixScaledMapped, but it doesn't support an acoustic scale, and it does support a frame offset, whereby you can state that the first row of 'likes' is actually the n'th row of the matrix of available log-likelihoods.
It's useful if the neural net output comes in chunks for different frame ranges.
Note: DecodableMatrixMappedOffset solves the same problem in a slightly different way, where you use the same decodable object. This one, unlike DecodableMatrixMappedOffset, is compatible with when the loglikes are in a SubMatrix.
Definition at line 98 of file decodable-matrix.h.
DecodableMatrixMapped | ( | const TransitionModel & | tm, |
const MatrixBase< BaseFloat > & | likes, | ||
int32 | frame_offset = 0 |
||
) |
Definition at line 24 of file decodable-matrix.cc.
References MatrixBase< Real >::Data(), KALDI_ERR, MatrixBase< Real >::NumCols(), TransitionModel::NumPdfs(), DecodableMatrixMapped::raw_data_, MatrixBase< Real >::Stride(), and DecodableMatrixMapped::stride_.
DecodableMatrixMapped | ( | const TransitionModel & | tm, |
const Matrix< BaseFloat > * | likes, | ||
int32 | frame_offset = 0 |
||
) |
Definition at line 39 of file decodable-matrix.cc.
References MatrixBase< Real >::Data(), DecodableMatrixMapped::frame_offset_, KALDI_ERR, MatrixBase< Real >::NumCols(), TransitionModel::NumPdfs(), DecodableMatrixMapped::raw_data_, MatrixBase< Real >::Stride(), and DecodableMatrixMapped::stride_.
|
virtual |
Definition at line 76 of file decodable-matrix.cc.
References DecodableMatrixMapped::likes_to_delete_.
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 66 of file decodable-matrix.cc.
References KALDI_ASSERT, and DecodableMatrixMapped::NumFramesReady().
|
private |
Returns the log likelihood, which will be negated in the decoder.
The "frame" starts from zero. You should verify that NumFramesReady() > frame before calling this.
Implements DecodableInterface.
Definition at line 53 of file decodable-matrix.cc.
References DecodableMatrixMapped::frame_offset_, DecodableMatrixMapped::likes_, DecodableMatrixMapped::raw_data_, DecodableMatrixMapped::stride_, DecodableMatrixMapped::trans_model_, and TransitionModel::TransitionIdToPdfFast().
|
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 62 of file decodable-matrix.cc.
References DecodableMatrixMapped::frame_offset_, and DecodableMatrixMapped::likes_.
Referenced by DecodableMatrixMapped::IsLastFrame().
|
virtual |
Returns the number of states in the acoustic model (they will be indexed one-based, i.e.
from 1 to NumIndices(); this is for compatibility with OpenFst).
Implements DecodableInterface.
Definition at line 72 of file decodable-matrix.cc.
References TransitionModel::NumTransitionIds(), and DecodableMatrixMapped::trans_model_.
|
private |
Definition at line 128 of file decodable-matrix.h.
Referenced by DecodableMatrixMappedOffset::AcceptLoglikes(), DecodableMatrixMapped::DecodableMatrixMapped(), DecodableMatrixMapped::LogLikelihood(), and DecodableMatrixMapped::NumFramesReady().
|
private |
Definition at line 126 of file decodable-matrix.h.
Referenced by DecodableMatrixMapped::LogLikelihood(), and DecodableMatrixMapped::NumFramesReady().
Definition at line 127 of file decodable-matrix.h.
Referenced by DecodableMatrixMapped::~DecodableMatrixMapped().
|
private |
Definition at line 132 of file decodable-matrix.h.
Referenced by DecodableMatrixMappedOffset::AcceptLoglikes(), DecodableMatrixMapped::DecodableMatrixMapped(), and DecodableMatrixMapped::LogLikelihood().
|
private |
Definition at line 133 of file decodable-matrix.h.
Referenced by DecodableMatrixMappedOffset::AcceptLoglikes(), DecodableMatrixMapped::DecodableMatrixMapped(), and DecodableMatrixMapped::LogLikelihood().
|
private |
Definition at line 125 of file decodable-matrix.h.
Referenced by DecodableMatrixMappedOffset::AcceptLoglikes(), DecodableMatrixMapped::LogLikelihood(), and DecodableMatrixMapped::NumIndices().