#include <context-dep.h>
Public Member Functions | |
virtual int32 | ContextWidth () const |
ContextWidth() returns the value N (e.g. More... | |
virtual int32 | CentralPosition () const |
Central position P of the phone context, in 0-based numbering, e.g. More... | |
virtual bool | Compute (const std::vector< int32 > &phoneseq, int32 pdf_class, int32 *pdf_id) const |
returns success or failure; outputs pdf to pdf_id For positions that were outside the sequence (due to end effects), put zero. More... | |
virtual int32 | NumPdfs () const |
NumPdfs() returns the number of acoustic pdfs (they are numbered 0.. NumPdfs()-1). More... | |
virtual ContextDependencyInterface * | Copy () const |
Returns pointer to new object which is copy of current one. More... | |
void | Read (std::istream &is, bool binary) |
Read context-dependency object from disk; throws on error. More... | |
ContextDependency () | |
ContextDependency (int32 N, int32 P, EventMap *to_pdf) | |
void | Write (std::ostream &os, bool binary) const |
~ContextDependency () | |
const EventMap & | ToPdfMap () const |
virtual void | GetPdfInfo (const std::vector< int32 > &phones, const std::vector< int32 > &num_pdf_classes, std::vector< std::vector< std::pair< int32, int32 > > > *pdf_info) const |
GetPdfInfo returns a vector indexed by pdf-id, saying for each pdf which pairs of (phone, pdf-class) it can correspond to. More... | |
virtual void | GetPdfInfo (const std::vector< int32 > &phones, const std::vector< std::vector< std::pair< int32, int32 > > > &pdf_class_pairs, std::vector< std::vector< std::vector< std::pair< int32, int32 > > > > *pdf_info) const |
This function outputs information about what possible pdf-ids can be generated for HMM-states; it covers the general case where the self-loop pdf-class may be different from the forward-transition pdf-class, so we are asking not about the set of possible pdf-ids for a given (phone, pdf-class), but the set of possible ordered pairs (forward-transition-pdf, self-loop-pdf) for a given (phone, forward-transition-pdf-class, self-loop-pdf-class). More... | |
Public Member Functions inherited from ContextDependencyInterface | |
virtual | ~ContextDependencyInterface () |
ContextDependencyInterface () | |
Private Member Functions | |
void | EnumeratePairs (const std::vector< int32 > &phones, int32 self_loop_pdf_class, int32 forward_pdf_class, const std::vector< int32 > &context, unordered_set< std::pair< int32, int32 >, PairHasher< int32 > > *pairs) const |
KALDI_DISALLOW_COPY_AND_ASSIGN (ContextDependency) | |
Private Attributes | |
int32 | N_ |
int32 | P_ |
EventMap * | to_pdf_ |
Definition at line 59 of file context-dep.h.
|
inline |
Definition at line 88 of file context-dep.h.
Referenced by ContextDependency::Copy(), kaldi::GenRandContextDependency(), kaldi::GenRandContextDependencyLarge(), kaldi::MonophoneContextDependency(), and kaldi::MonophoneContextDependencyShared().
|
inline |
|
inline |
|
inlinevirtual |
Central position P of the phone context, in 0-based numbering, e.g.
P = 1 for typical triphone system. We have to see if we can do without this function.
Implements ContextDependencyInterface.
Definition at line 62 of file context-dep.h.
References ContextDependency::Compute(), and ContextDependency::P_.
Referenced by TrainingGraphCompiler::CompileGraph(), TrainingGraphCompiler::CompileGraphs(), kaldi::InitAmGmmFromOld(), main(), and TrainingGraphCompiler::TrainingGraphCompiler().
|
virtual |
returns success or failure; outputs pdf to pdf_id For positions that were outside the sequence (due to end effects), put zero.
Naturally phoneseq[CentralPosition()] must be nonzero.
Implements ContextDependencyInterface.
Definition at line 26 of file context-dep.cc.
References rnnlm::i, KALDI_ASSERT, KALDI_COMPILE_TIME_ASSERT, kaldi::kPdfClass, EventMap::Map(), ContextDependency::N_, and ContextDependency::to_pdf_.
Referenced by ContextDependency::CentralPosition().
|
inlinevirtual |
ContextWidth() returns the value N (e.g.
3 for triphone models) that says how many phones are considered for computing context.
Implements ContextDependencyInterface.
Definition at line 61 of file context-dep.h.
References ContextDependency::N_.
Referenced by TrainingGraphCompiler::CompileGraph(), TrainingGraphCompiler::CompileGraphs(), kaldi::InitAmGmmFromOld(), main(), and TrainingGraphCompiler::TrainingGraphCompiler().
|
inlinevirtual |
Returns pointer to new object which is copy of current one.
Implements ContextDependencyInterface.
Definition at line 79 of file context-dep.h.
References ContextDependency::ContextDependency(), EventMap::Copy(), ContextDependency::N_, ContextDependency::P_, ContextDependency::Read(), and ContextDependency::to_pdf_.
|
private |
Definition at line 181 of file context-dep.cc.
References rnnlm::i, KALDI_ASSERT, kaldi::kPdfClass, EventMap::MultiMap(), rnnlm::n, ContextDependency::N_, ContextDependency::P_, kaldi::SortAndUniq(), and ContextDependency::to_pdf_.
Referenced by ContextDependency::GetPdfInfo().
|
virtual |
GetPdfInfo returns a vector indexed by pdf-id, saying for each pdf which pairs of (phone, pdf-class) it can correspond to.
(Usually just one). c.f. hmm/hmm-topology.h for meaning of pdf-class. This is the old, simpler interface of GetPdfInfo(), and that this one can only be called if the HmmTopology object's IsHmm() function call returns true.
Implements ContextDependencyInterface.
Definition at line 287 of file context-dep.cc.
References rnnlm::i, kaldi::IsSortedAndUniq(), rnnlm::j, KALDI_ASSERT, KALDI_WARN, kaldi::kPdfClass, EventMap::MultiMap(), ContextDependency::NumPdfs(), ContextDependency::P_, kaldi::SortAndUniq(), and ContextDependency::to_pdf_.
Referenced by kaldi::TestGenRandContextDependency(), kaldi::TestMonophoneContextDependency(), and ContextDependency::ToPdfMap().
|
virtual |
This function outputs information about what possible pdf-ids can be generated for HMM-states; it covers the general case where the self-loop pdf-class may be different from the forward-transition pdf-class, so we are asking not about the set of possible pdf-ids for a given (phone, pdf-class), but the set of possible ordered pairs (forward-transition-pdf, self-loop-pdf) for a given (phone, forward-transition-pdf-class, self-loop-pdf-class).
Note: 'phones' is a list of integer ids of phones, and 'pdf-class-pairs', indexed by phone, is a list of pairs (forward-transition-pdf-class, self-loop-pdf-class) that we can have for that phone. The output 'pdf_info' is indexed first by phone and then by the same index that indexes each element of 'pdf_class_pairs', and tells us for each pair in 'pdf_class_pairs', what is the list of possible (forward-transition-pdf-id, self-loop-pdf-id) that we can have. This is less efficient than the other version of GetPdfInfo(). Note: if there is no self-loop, the corresponding entry (.second) in pdf_class_pairs and the output pdf_info would be -1.
Implements ContextDependencyInterface.
Definition at line 257 of file context-dep.cc.
References ContextDependency::EnumeratePairs(), rnnlm::i, rnnlm::j, KALDI_ASSERT, ContextDependency::N_, and ContextDependency::P_.
|
private |
|
inlinevirtual |
NumPdfs() returns the number of acoustic pdfs (they are numbered 0.. NumPdfs()-1).
Implements ContextDependencyInterface.
Definition at line 71 of file context-dep.h.
References EventMap::MaxResult(), and ContextDependency::to_pdf_.
Referenced by ContextDependency::GetPdfInfo(), and main().
void Read | ( | std::istream & | is, |
bool | binary | ||
) |
Read context-dependency object from disk; throws on error.
Definition at line 155 of file context-dep.cc.
References kaldi::ExpectToken(), KALDI_ERR, ContextDependency::N_, ContextDependency::P_, EventMap::Read(), kaldi::ReadBasicType(), kaldi::ReadToken(), and ContextDependency::to_pdf_.
Referenced by ContextDependency::Copy(), kaldi::InitAmGmmFromOld(), main(), and kaldi::TestGenRandContextDependency().
|
inline |
Definition at line 98 of file context-dep.h.
References ContextDependency::GetPdfInfo(), and ContextDependency::to_pdf_.
Referenced by kaldi::InitAmGmmFromOld(), and main().
void Write | ( | std::ostream & | os, |
bool | binary | ||
) | const |
Definition at line 145 of file context-dep.cc.
References ContextDependency::N_, ContextDependency::P_, ContextDependency::to_pdf_, EventMap::Write(), kaldi::WriteBasicType(), and kaldi::WriteToken().
Referenced by ContextDependency::ContextDependency(), main(), and kaldi::TestGenRandContextDependency().
|
private |
Definition at line 138 of file context-dep.h.
Referenced by ContextDependency::Compute(), ContextDependency::ContextWidth(), ContextDependency::Copy(), ContextDependency::EnumeratePairs(), ContextDependency::GetPdfInfo(), ContextDependency::Read(), and ContextDependency::Write().
|
private |
Definition at line 139 of file context-dep.h.
Referenced by ContextDependency::CentralPosition(), ContextDependency::Copy(), ContextDependency::EnumeratePairs(), ContextDependency::GetPdfInfo(), ContextDependency::Read(), and ContextDependency::Write().
|
private |
Definition at line 140 of file context-dep.h.
Referenced by ContextDependency::Compute(), ContextDependency::Copy(), ContextDependency::EnumeratePairs(), ContextDependency::GetPdfInfo(), ContextDependency::NumPdfs(), ContextDependency::Read(), ContextDependency::ToPdfMap(), ContextDependency::Write(), and ContextDependency::~ContextDependency().