DecodableMatrixScaledMapped Class Reference

#include <decodable-matrix.h>

Inheritance diagram for DecodableMatrixScaledMapped:
Collaboration diagram for DecodableMatrixScaledMapped:

Public Member Functions

 DecodableMatrixScaledMapped (const TransitionModel &tm, const Matrix< BaseFloat > &likes, BaseFloat scale)
 
 DecodableMatrixScaledMapped (const TransitionModel &tm, BaseFloat scale, const Matrix< BaseFloat > *likes)
 
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 ~DecodableMatrixScaledMapped ()
 
- Public Member Functions inherited from DecodableInterface
virtual ~DecodableInterface ()
 

Private Member Functions

 KALDI_DISALLOW_COPY_AND_ASSIGN (DecodableMatrixScaledMapped)
 

Private Attributes

const TransitionModeltrans_model_
 
const Matrix< BaseFloat > * likes_
 
BaseFloat scale_
 
bool delete_likes_
 

Detailed Description

Definition at line 34 of file decodable-matrix.h.

Constructor & Destructor Documentation

◆ DecodableMatrixScaledMapped() [1/2]

DecodableMatrixScaledMapped ( const TransitionModel tm,
const Matrix< BaseFloat > &  likes,
BaseFloat  scale 
)
inline

Definition at line 37 of file decodable-matrix.h.

References KALDI_ERR, MatrixBase< Real >::NumCols(), and TransitionModel::NumPdfs().

39  : trans_model_(tm), likes_(&likes),
40  scale_(scale), delete_likes_(false) {
41  if (likes.NumCols() != tm.NumPdfs())
42  KALDI_ERR << "DecodableMatrixScaledMapped: mismatch, matrix has "
43  << likes.NumCols() << " cols but transition-model has "
44  << tm.NumPdfs() << " pdf-ids.";
45  }
const TransitionModel & trans_model_
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
Definition: kaldi-matrix.h:67
#define KALDI_ERR
Definition: kaldi-error.h:147
const Matrix< BaseFloat > * likes_

◆ DecodableMatrixScaledMapped() [2/2]

DecodableMatrixScaledMapped ( const TransitionModel tm,
BaseFloat  scale,
const Matrix< BaseFloat > *  likes 
)
inline

Definition at line 49 of file decodable-matrix.h.

References KALDI_ERR, MatrixBase< Real >::NumCols(), and TransitionModel::NumPdfs().

51  :
52  trans_model_(tm), likes_(likes),
53  scale_(scale), delete_likes_(true) {
54  if (likes->NumCols() != tm.NumPdfs())
55  KALDI_ERR << "DecodableMatrixScaledMapped: mismatch, matrix has "
56  << likes->NumCols() << " cols but transition-model has "
57  << tm.NumPdfs() << " pdf-ids.";
58  }
const TransitionModel & trans_model_
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
Definition: kaldi-matrix.h:67
#define KALDI_ERR
Definition: kaldi-error.h:147
const Matrix< BaseFloat > * likes_

◆ ~DecodableMatrixScaledMapped()

virtual ~DecodableMatrixScaledMapped ( )
inlinevirtual

Member Function Documentation

◆ IsLastFrame()

virtual bool IsLastFrame ( int32  frame) const
inlinevirtual

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 62 of file decodable-matrix.h.

References KALDI_ASSERT, and DecodableMatrixScaledMapped::NumFramesReady().

62  {
63  KALDI_ASSERT(frame < NumFramesReady());
64  return (frame == NumFramesReady() - 1);
65  }
virtual int32 NumFramesReady() const
The call NumFramesReady() will return the number of frames currently available for this decodable obj...
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

◆ KALDI_DISALLOW_COPY_AND_ASSIGN()

KALDI_DISALLOW_COPY_AND_ASSIGN ( DecodableMatrixScaledMapped  )
private

◆ LogLikelihood()

virtual BaseFloat LogLikelihood ( int32  frame,
int32  index 
)
inlinevirtual

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 68 of file decodable-matrix.h.

References DecodableMatrixScaledMapped::scale_, DecodableMatrixScaledMapped::trans_model_, and TransitionModel::TransitionIdToPdfFast().

68  {
69  return scale_ * (*likes_)(frame, trans_model_.TransitionIdToPdfFast(tid));
70  }
const TransitionModel & trans_model_
int32 TransitionIdToPdfFast(int32 trans_id) const

◆ NumFramesReady()

virtual int32 NumFramesReady ( ) const
inlinevirtual

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 60 of file decodable-matrix.h.

References DecodableMatrixScaledMapped::likes_, and MatrixBase< Real >::NumRows().

Referenced by DecodableMatrixScaledMapped::IsLastFrame(), DecodableMatrixMappedOffset::IsLastFrame(), and DecodableMatrixScaled::IsLastFrame().

60 { return likes_->NumRows(); }
const Matrix< BaseFloat > * likes_
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition: kaldi-matrix.h:64

◆ NumIndices()

virtual int32 NumIndices ( ) const
inlinevirtual

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 73 of file decodable-matrix.h.

References TransitionModel::NumTransitionIds(), and DecodableMatrixScaledMapped::trans_model_.

73 { return trans_model_.NumTransitionIds(); }
const TransitionModel & trans_model_
int32 NumTransitionIds() const
Returns the total number of transition-ids (note, these are one-based).

Member Data Documentation

◆ delete_likes_

bool delete_likes_
private

◆ likes_

◆ scale_

◆ trans_model_


The documentation for this class was generated from the following file: