Classes | |
class | PosteriorHolder |
class | GaussPostHolder |
struct | CompareReverseSecond |
Typedefs | |
typedef std::vector< std::vector< std::pair< int32, BaseFloat > > > | Posterior |
Posterior is a typedef for storing acoustic-state (actually, transition-id) posteriors over an utterance. More... | |
typedef std::vector< std::vector< std::pair< int32, Vector< BaseFloat > > > > | GaussPost |
GaussPost is a typedef for storing Gaussian-level posteriors for an utterance. More... | |
typedef TableWriter< PosteriorHolder > | PosteriorWriter |
typedef SequentialTableReader< PosteriorHolder > | SequentialPosteriorReader |
typedef RandomAccessTableReader< PosteriorHolder > | RandomAccessPosteriorReader |
typedef TableWriter< GaussPostHolder > | GaussPostWriter |
typedef SequentialTableReader< GaussPostHolder > | SequentialGaussPostReader |
typedef RandomAccessTableReader< GaussPostHolder > | RandomAccessGaussPostReader |
Functions | |
void | WritePosterior (std::ostream &os, bool binary, const Posterior &post) |
stand-alone function for writing a Posterior. More... | |
void | ReadPosterior (std::istream &os, bool binary, Posterior *post) |
stand-alone function for reading a Posterior. More... | |
void | ScalePosterior (BaseFloat scale, Posterior *post) |
Scales the BaseFloat (weight) element in the posterior entries. More... | |
BaseFloat | TotalPosterior (const Posterior &post) |
Returns the total of all the weights in "post". More... | |
bool | PosteriorEntriesAreDisjoint (const std::vector< std::pair< int32, BaseFloat > > &post_elem1, const std::vector< std::pair< int32, BaseFloat > > &post_elem2) |
Returns true if the two lists of pairs have no common .first element. More... | |
int32 | MergePosteriors (const Posterior &post1, const Posterior &post2, bool merge, bool drop_frames, Posterior *post) |
Merge two sets of posteriors, which must have the same length. More... | |
BaseFloat | VectorToPosteriorEntry (const VectorBase< BaseFloat > &log_likes, int32 num_gselect, BaseFloat min_post, std::vector< std::pair< int32, BaseFloat > > *post_entry) |
Given a vector of log-likelihoods (typically of Gaussians in a GMM but could be of pdf-ids), a number gselect >= 1 and a minimum posterior 0 <= min_post < 1, it gets the posterior for each element of log-likes by applying Softmax(), then prunes the posteriors using "gselect" and "min_post" (keeping at least one), and outputs the result into "post_entry", sorted from greatest to least posterior. More... | |
void | AlignmentToPosterior (const std::vector< int32 > &ali, Posterior *post) |
Convert an alignment to a posterior (with a scale of 1.0 on each entry). More... | |
void | SortPosteriorByPdfs (const TransitionModel &tmodel, Posterior *post) |
Sorts posterior entries so that transition-ids with same pdf-id are next to each other. More... | |
void | ConvertPosteriorToPdfs (const TransitionModel &tmodel, const Posterior &post_in, Posterior *post_out) |
Converts a posterior over transition-ids to be a posterior over pdf-ids. More... | |
void | ConvertPosteriorToPhones (const TransitionModel &tmodel, const Posterior &post_in, Posterior *post_out) |
Converts a posterior over transition-ids to be a posterior over phones. More... | |
void | WeightSilencePost (const TransitionModel &trans_model, const ConstIntegerSet< int32 > &silence_set, BaseFloat silence_scale, Posterior *post) |
Weight any silence phones in the posterior (i.e. More... | |
void | WeightSilencePostDistributed (const TransitionModel &trans_model, const ConstIntegerSet< int32 > &silence_set, BaseFloat silence_scale, Posterior *post) |
This is similar to WeightSilencePost, except that on each frame it works out the amount by which the overall posterior would be reduced, and scales down everything on that frame by the same amount. More... | |
template<typename Real > | |
void | PosteriorToMatrix (const Posterior &post, const int32 post_dim, Matrix< Real > *mat) |
This converts a Posterior to a Matrix. More... | |
template<typename Real > | |
void | PosteriorToPdfMatrix (const Posterior &post, const TransitionModel &model, Matrix< Real > *mat) |
This converts a Posterior to a Matrix. More... | |
GaussPost is a typedef for storing Gaussian-level posteriors for an utterance.
the "int32" is a transition-id, and the Vector<BaseFloat> is a vector of Gaussian posteriors. WARNING: We changed "int32" from transition-id to pdf-id, and the change is applied for all programs using GaussPost. This is for efficiency purpose. We also changed the name slightly from GauPost to GaussPost to reduce the chance that the change will go un-noticed in downstream code.
Definition at line 51 of file posterior.h.
typedef TableWriter<GaussPostHolder> GaussPostWriter |
Definition at line 144 of file posterior.h.
Posterior is a typedef for storing acoustic-state (actually, transition-id) posteriors over an utterance.
The "int32" is a transition-id, and the BaseFloat is a probability (typically between zero and one).
Definition at line 42 of file posterior.h.
typedef TableWriter<PosteriorHolder> PosteriorWriter |
Definition at line 138 of file posterior.h.
Definition at line 146 of file posterior.h.
Definition at line 140 of file posterior.h.
Definition at line 145 of file posterior.h.
Definition at line 139 of file posterior.h.
Convert an alignment to a posterior (with a scale of 1.0 on each entry).
Definition at line 290 of file posterior.cc.
References rnnlm::i.
Referenced by DiscriminativeComputation::ComputeObjfAndDeriv(), kaldi::LatticeForwardBackwardMmi(), main(), and CompareReverseSecond::operator()().
void ConvertPosteriorToPdfs | ( | const TransitionModel & | tmodel, |
const Posterior & | post_in, | ||
Posterior * | post_out | ||
) |
Converts a posterior over transition-ids to be a posterior over pdf-ids.
Definition at line 322 of file posterior.cc.
References rnnlm::i, rnnlm::j, and TransitionModel::TransitionIdToPdf().
Referenced by kaldi::AccStatsForUtterance(), kaldi::AccumulateForUtterance(), DiscriminativeComputation::ComputeObjfAndDeriv(), kaldi::nnet2::ExampleToPdfPost(), NnetDiscriminativeUpdater::GetDiscriminativePosteriors(), SingleUtteranceGmmDecoder::GetGaussianPosteriors(), kaldi::LatticeForwardBackwardMmi(), main(), and CompareReverseSecond::operator()().
void ConvertPosteriorToPhones | ( | const TransitionModel & | tmodel, |
const Posterior & | post_in, | ||
Posterior * | post_out | ||
) |
Converts a posterior over transition-ids to be a posterior over phones.
Definition at line 348 of file posterior.cc.
References rnnlm::i, rnnlm::j, and TransitionModel::TransitionIdToPhone().
Referenced by main(), and CompareReverseSecond::operator()().
int32 MergePosteriors | ( | const Posterior & | post1, |
const Posterior & | post2, | ||
bool | merge, | ||
bool | drop_frames, | ||
Posterior * | post | ||
) |
Merge two sets of posteriors, which must have the same length.
If "merge" is true, it will make a common entry whenever there are duplicated entries, adding up the weights. If "drop_frames" is true, for frames where the two sets of posteriors were originally disjoint, makes no entries for that frame (relates to frame dropping, or drop_frames, see Vesely et al, ICASSP 2013). Returns the number of frames for which the two posteriors were disjoint (i.e. no common transition-ids or whatever index we are using).
Definition at line 258 of file posterior.cc.
References rnnlm::i, KALDI_ASSERT, kaldi::MergePairVectorSumming(), and kaldi::PosteriorEntriesAreDisjoint().
Referenced by kaldi::LatticeForwardBackwardMmi(), and main().
bool PosteriorEntriesAreDisjoint | ( | const std::vector< std::pair< int32, BaseFloat > > & | post_elem1, |
const std::vector< std::pair< int32, BaseFloat > > & | post_elem2 | ||
) |
Returns true if the two lists of pairs have no common .first element.
Definition at line 242 of file posterior.cc.
References rnnlm::i.
Referenced by kaldi::MergePosteriors().
This converts a Posterior to a Matrix.
The number of matrix-rows is the same as the 'post.size()', the number of matrix-columns is defined by 'post_dim'. The elements which are not specified in 'Posterior' are equal to zero.
Definition at line 512 of file posterior.cc.
References rnnlm::i, KALDI_ERR, kaldi::kSetZero, kaldi::PosteriorToMatrix< double >(), kaldi::PosteriorToMatrix< float >(), and Matrix< Real >::Resize().
Referenced by kaldi::AppendPostToFeats(), main(), and CompareReverseSecond::operator()().
void PosteriorToPdfMatrix | ( | const Posterior & | post, |
const TransitionModel & | model, | ||
Matrix< Real > * | mat | ||
) |
This converts a Posterior to a Matrix.
The number of matrix-rows is the same as the 'post.size()', the number of matrix-columns is defined by 'NumPdfs' in the TransitionModel. The elements which are not specified in 'Posterior' are equal to zero.
Definition at line 539 of file posterior.cc.
References rnnlm::i, KALDI_ERR, kaldi::kSetZero, TransitionModel::NumPdfs(), kaldi::PosteriorToPdfMatrix< double >(), kaldi::PosteriorToPdfMatrix< float >(), Matrix< Real >::Resize(), and TransitionModel::TransitionIdToPdf().
Referenced by CompareReverseSecond::operator()().
stand-alone function for reading a Posterior.
Definition at line 64 of file posterior.cc.
References kaldi::ConvertStringToInteger(), rnnlm::i, KALDI_ERR, and kaldi::ReadBasicType().
Referenced by main(), PosteriorHolder::Read(), and kaldi::TestPosteriorIo().
Scales the BaseFloat (weight) element in the posterior entries.
Definition at line 218 of file posterior.cc.
References rnnlm::i, and rnnlm::j.
Referenced by kaldi::nnet2::ExampleToPdfPost(), NnetDiscriminativeUpdater::LatticeComputations(), kaldi::LatticeForwardBackwardMmi(), main(), and kaldi::RunPerSpeaker().
void SortPosteriorByPdfs | ( | const TransitionModel & | tmodel, |
Posterior * | post | ||
) |
Sorts posterior entries so that transition-ids with same pdf-id are next to each other.
Definition at line 314 of file posterior.cc.
References rnnlm::i.
Referenced by main(), and CompareReverseSecond::operator()().
Returns the total of all the weights in "post".
Definition at line 230 of file posterior.cc.
References rnnlm::i.
Referenced by main(), and IvectorExtractTask::~IvectorExtractTask().
BaseFloat VectorToPosteriorEntry | ( | const VectorBase< BaseFloat > & | log_likes, |
int32 | num_gselect, | ||
BaseFloat | min_post, | ||
std::vector< std::pair< int32, BaseFloat > > * | post_entry | ||
) |
Given a vector of log-likelihoods (typically of Gaussians in a GMM but could be of pdf-ids), a number gselect >= 1 and a minimum posterior 0 <= min_post < 1, it gets the posterior for each element of log-likes by applying Softmax(), then prunes the posteriors using "gselect" and "min_post" (keeping at least one), and outputs the result into "post_entry", sorted from greatest to least posterior.
It returns the log of the sum of the selected log-likes that contributed to the posterior.
Definition at line 440 of file posterior.cc.
References VectorBase< Real >::Dim(), kaldi::Exp(), kaldi::GetTotalPosterior(), KALDI_ASSERT, kaldi::Log(), and VectorBase< Real >::Max().
Referenced by main(), CompareReverseSecond::operator()(), kaldi::TestVectorToPosteriorEntry(), and OnlineIvectorFeature::UpdateStatsForFrames().
void WeightSilencePost | ( | const TransitionModel & | trans_model, |
const ConstIntegerSet< int32 > & | silence_set, | ||
BaseFloat | silence_scale, | ||
Posterior * | post | ||
) |
Weight any silence phones in the posterior (i.e.
any phones in the set "silence_set" by scale "silence_scale". The interface was changed in Feb 2014 to do the modification "in-place" rather than having separate input and output.
Definition at line 375 of file posterior.cc.
References ConstIntegerSet< I >::count(), rnnlm::i, rnnlm::j, and TransitionModel::TransitionIdToPhone().
Referenced by SingleUtteranceGmmDecoder::GetGaussianPosteriors(), main(), and CompareReverseSecond::operator()().
void WeightSilencePostDistributed | ( | const TransitionModel & | trans_model, |
const ConstIntegerSet< int32 > & | silence_set, | ||
BaseFloat | silence_scale, | ||
Posterior * | post | ||
) |
This is similar to WeightSilencePost, except that on each frame it works out the amount by which the overall posterior would be reduced, and scales down everything on that frame by the same amount.
It has the effect that frames that are mostly silence get down-weighted. The interface was changed in Feb 2014 to do the modification "in-place" rather than having separate input and output.
Definition at line 398 of file posterior.cc.
References ConstIntegerSet< I >::count(), rnnlm::i, rnnlm::j, KALDI_ASSERT, and TransitionModel::TransitionIdToPhone().
Referenced by main(), and CompareReverseSecond::operator()().
stand-alone function for writing a Posterior.
Definition at line 32 of file posterior.cc.
References KALDI_ERR, and kaldi::WriteBasicType().
Referenced by kaldi::TestPosteriorIo(), and PosteriorHolder::Write().