DecodableSum Class Reference

#include <decodable-sum.h>

Inheritance diagram for DecodableSum:
Collaboration diagram for DecodableSum:

Public Member Functions

 DecodableSum (DecodableInterface *d1, BaseFloat w1, DecodableInterface *d2, BaseFloat w2)
 
 DecodableSum (const std::vector< std::pair< DecodableInterface *, BaseFloat > > &decodables)
 
void CheckSizes () const
 
virtual BaseFloat LogLikelihood (int32 frame, int32 state_index)
 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 bool IsLastFrame (int32 frame) const
 Returns true if this is the last frame. More...
 
- Public Member Functions inherited from DecodableInterface
virtual int32 NumFramesReady () const
 The call NumFramesReady() will return the number of frames currently available for this decodable object. More...
 
virtual ~DecodableInterface ()
 

Private Member Functions

 KALDI_DISALLOW_COPY_AND_ASSIGN (DecodableSum)
 

Private Attributes

std::vector< std::pair< DecodableInterface *, BaseFloat > > decodables_
 

Detailed Description

Definition at line 36 of file decodable-sum.h.

Constructor & Destructor Documentation

◆ DecodableSum() [1/2]

DecodableSum ( DecodableInterface d1,
BaseFloat  w1,
DecodableInterface d2,
BaseFloat  w2 
)
inline

Definition at line 40 of file decodable-sum.h.

References DecodableSum::CheckSizes(), and DecodableSum::decodables_.

41  {
42  decodables_.push_back(std::make_pair(d1, w1));
43  decodables_.push_back(std::make_pair(d2, w2));
44  CheckSizes();
45  }
void CheckSizes() const
Definition: decodable-sum.h:52
std::vector< std::pair< DecodableInterface *, BaseFloat > > decodables_
Definition: decodable-sum.h:82

◆ DecodableSum() [2/2]

DecodableSum ( const std::vector< std::pair< DecodableInterface *, BaseFloat > > &  decodables)
inline

Definition at line 48 of file decodable-sum.h.

References DecodableSum::CheckSizes().

49  :
50  decodables_(decodables) { CheckSizes(); }
void CheckSizes() const
Definition: decodable-sum.h:52
std::vector< std::pair< DecodableInterface *, BaseFloat > > decodables_
Definition: decodable-sum.h:82

Member Function Documentation

◆ CheckSizes()

void CheckSizes ( ) const
inline

Definition at line 52 of file decodable-sum.h.

References DecodableSum::decodables_, rnnlm::i, and KALDI_ASSERT.

Referenced by DecodableSum::DecodableSum().

52  {
53  KALDI_ASSERT(decodables_.size() >= 1
54  && decodables_[0].first != NULL);
55  for (size_t i = 1; i < decodables_.size(); i++)
56  KALDI_ASSERT(decodables_[i].first != NULL &&
57  decodables_[i].first->NumIndices() ==
58  decodables_[0].first->NumIndices());
59  }
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
std::vector< std::pair< DecodableInterface *, BaseFloat > > decodables_
Definition: decodable-sum.h:82

◆ 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 76 of file decodable-sum.h.

References DecodableSum::decodables_.

76  {
77  // We require all the decodables have the same #frames. We don't check this though.
78  return decodables_[0].first->IsLastFrame(frame);
79  }
std::vector< std::pair< DecodableInterface *, BaseFloat > > decodables_
Definition: decodable-sum.h:82

◆ KALDI_DISALLOW_COPY_AND_ASSIGN()

KALDI_DISALLOW_COPY_AND_ASSIGN ( DecodableSum  )
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.

Reimplemented in DecodableSumScaled.

Definition at line 63 of file decodable-sum.h.

References DecodableSum::decodables_.

Referenced by DecodableSumScaled::LogLikelihood().

63  {
64  BaseFloat sum = 0.0;
65  // int32 i=1;
66  for (std::vector<std::pair<DecodableInterface*, BaseFloat> >::iterator iter = decodables_.begin();
67  iter != decodables_.end();
68  ++iter) {
69  sum += iter->first->LogLikelihood(frame, state_index) * iter->second;
70  }
71  return sum;
72  }
float BaseFloat
Definition: kaldi-types.h:29
std::vector< std::pair< DecodableInterface *, BaseFloat > > decodables_
Definition: decodable-sum.h:82

◆ 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 74 of file decodable-sum.h.

References DecodableSum::decodables_.

74 { return decodables_[0].first->NumIndices(); }
std::vector< std::pair< DecodableInterface *, BaseFloat > > decodables_
Definition: decodable-sum.h:82

Member Data Documentation

◆ decodables_


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