Definition for Gaussian Mixture Model with full covariances. More...
#include <full-gmm.h>
Public Member Functions | |
FullGmm () | |
Empty constructor. More... | |
FullGmm (const FullGmm &gmm) | |
FullGmm (int32 nMix, int32 dim) | |
void | Resize (int32 nMix, int32 dim) |
Resizes arrays to this dim. Does not initialize data. More... | |
int32 | NumGauss () const |
Returns the number of mixture components in the GMM. More... | |
int32 | Dim () const |
Returns the dimensionality of the Gaussian mean vectors. More... | |
void | CopyFromFullGmm (const FullGmm &fullgmm) |
Copies from given FullGmm. More... | |
void | CopyFromDiagGmm (const DiagGmm &diaggmm) |
Copies from given DiagGmm. More... | |
BaseFloat | LogLikelihood (const VectorBase< BaseFloat > &data) const |
Returns the log-likelihood of a data point (vector) given the GMM. More... | |
void | LogLikelihoods (const VectorBase< BaseFloat > &data, Vector< BaseFloat > *loglikes) const |
Outputs the per-component contributions to the log-likelihood. More... | |
void | LogLikelihoodsPreselect (const VectorBase< BaseFloat > &data, const std::vector< int32 > &indices, Vector< BaseFloat > *loglikes) const |
Outputs the per-component log-likelihoods of a subset of mixture components. More... | |
BaseFloat | GaussianSelection (const VectorBase< BaseFloat > &data, int32 num_gselect, std::vector< int32 > *output) const |
Get gaussian selection information for one frame. More... | |
BaseFloat | GaussianSelectionPreselect (const VectorBase< BaseFloat > &data, const std::vector< int32 > &preselect, int32 num_gselect, std::vector< int32 > *output) const |
Get gaussian selection information for one frame. More... | |
BaseFloat | ComponentPosteriors (const VectorBase< BaseFloat > &data, VectorBase< BaseFloat > *posterior) const |
Computes the posterior probabilities of all Gaussian components given a data point. More... | |
BaseFloat | ComponentLogLikelihood (const VectorBase< BaseFloat > &data, int32 comp_id) const |
Computes the contribution log-likelihood of a data point from a single Gaussian component. More... | |
int32 | ComputeGconsts () |
Sets the gconsts. More... | |
void | Split (int32 target_components, float perturb_factor, std::vector< int32 > *history=NULL) |
Merge the components and remember the order in which the components were merged (flat list of pairs) More... | |
void | Perturb (float perturb_factor) |
Perturbs the component means with a random vector multiplied by the pertrub factor. More... | |
void | Merge (int32 target_components, std::vector< int32 > *history=NULL) |
Merge the components and remember the order in which the components were merged (flat list of pairs) More... | |
BaseFloat | MergePreselect (int32 target_components, const std::vector< std::pair< int32, int32 > > &preselect_pairs) |
Merge the components and remember the order in which the components were merged (flat list of pairs); this version only considers merging pairs in "preselect_pairs" (or their descendants after merging). More... | |
void | Write (std::ostream &os, bool binary) const |
void | Read (std::istream &is, bool binary) |
void | Interpolate (BaseFloat rho, const FullGmm &source, GmmFlagsType flags=kGmmAll) |
this = rho x source + (1-rho) x this More... | |
const Vector< BaseFloat > & | gconsts () const |
Const accessors. More... | |
const Vector< BaseFloat > & | weights () const |
const Matrix< BaseFloat > & | means_invcovars () const |
const std::vector< SpMatrix< BaseFloat > > & | inv_covars () const |
Matrix< BaseFloat > & | means_invcovars () |
Non-const accessors. More... | |
std::vector< SpMatrix< BaseFloat > > & | inv_covars () |
template<class Real > | |
void | SetWeights (const Vector< Real > &w) |
Mutators for both float or double. More... | |
template<class Real > | |
void | SetMeans (const Matrix< Real > &m) |
Use SetMeans to update only the Gaussian means (and not variances) More... | |
template<class Real > | |
void | SetInvCovarsAndMeans (const std::vector< SpMatrix< Real > > &invcovars, const Matrix< Real > &means) |
Use SetInvCovarsAndMeans if updating both means and (inverse) covariances. More... | |
template<class Real > | |
void | SetInvCovarsAndMeansInvCovars (const std::vector< SpMatrix< Real > > &invcovars, const Matrix< Real > &means_invcovars) |
Use this if setting both, in the class's native format. More... | |
template<class Real > | |
void | SetInvCovars (const std::vector< SpMatrix< Real > > &v) |
Set the (inverse) covariances and recompute means_invcovars_. More... | |
template<class Real > | |
void | GetCovars (std::vector< SpMatrix< Real > > *v) const |
Accessor for covariances. More... | |
template<class Real > | |
void | GetMeans (Matrix< Real > *m) const |
Accessor for means. More... | |
template<class Real > | |
void | GetCovarsAndMeans (std::vector< SpMatrix< Real > > *covars, Matrix< Real > *means) const |
Accessor for covariances and means. More... | |
void | RemoveComponent (int32 gauss, bool renorm_weights) |
Mutators for single component, supports float or double Removes single component from model. More... | |
void | RemoveComponents (const std::vector< int32 > &gauss, bool renorm_weights) |
Removes multiple components from model; "gauss" must not have dups. More... | |
template<class Real > | |
void | GetComponentMean (int32 gauss, VectorBase< Real > *out) const |
Accessor for component mean. More... | |
Private Member Functions | |
void | ResizeInvCovars (int32 nMix, int32 dim) |
Resizes arrays to this dim. Does not initialize data. More... | |
BaseFloat | MergedComponentsLogdet (BaseFloat w1, BaseFloat w2, const VectorBase< BaseFloat > &f1, const VectorBase< BaseFloat > &f2, const SpMatrix< BaseFloat > &s1, const SpMatrix< BaseFloat > &s2) const |
const FullGmm & | operator= (const FullGmm &other) |
Private Attributes | |
Vector< BaseFloat > | gconsts_ |
Equals log(weight) - 0.5 * (log det(var) + mean'*inv(var)*mean) More... | |
bool | valid_gconsts_ |
Recompute gconsts_ if false. More... | |
Vector< BaseFloat > | weights_ |
weights (not log). More... | |
std::vector< SpMatrix< BaseFloat > > | inv_covars_ |
Inverse covariances. More... | |
Matrix< BaseFloat > | means_invcovars_ |
Means times inverse covariances. More... | |
Friends | |
class | FullGmmNormal |
this makes it a little easier to modify the internals More... | |
Definition for Gaussian Mixture Model with full covariances.
Definition at line 40 of file full-gmm.h.
|
inline |
Empty constructor.
Definition at line 46 of file full-gmm.h.
Referenced by FullGmm::Split().
Definition at line 48 of file full-gmm.h.
References FullGmm::CopyFromFullGmm().
Definition at line 52 of file full-gmm.h.
References FullGmm::Resize().
BaseFloat ComponentLogLikelihood | ( | const VectorBase< BaseFloat > & | data, |
int32 | comp_id | ||
) | const |
Computes the contribution log-likelihood of a data point from a single Gaussian component.
NOTE: Currently we make no guarantees about what happens if one of the variances is zero.
Definition at line 562 of file full-gmm.cc.
References FullGmm::Dim(), VectorBase< Real >::Dim(), FullGmm::gconsts_, FullGmm::inv_covars_, KALDI_ERR, FullGmm::means_invcovars_, MatrixBase< Real >::Row(), FullGmm::valid_gconsts_, kaldi::VecSpVec(), and kaldi::VecVec().
Referenced by FullGmm::Dim().
BaseFloat ComponentPosteriors | ( | const VectorBase< BaseFloat > & | data, |
VectorBase< BaseFloat > * | posterior | ||
) | const |
Computes the posterior probabilities of all Gaussian components given a data point.
Returns the log-likehood of the data given the GMM.
Definition at line 719 of file full-gmm.cc.
References VectorBase< Real >::ApplySoftMax(), VectorBase< Real >::CopyFromVec(), KALDI_ERR, KALDI_ISINF, KALDI_ISNAN, and FullGmm::LogLikelihoods().
Referenced by IvectorExtractorStats::AccStatsForUtterance(), AccumFullGmm::AccumulateFromFull(), FullGmm::Dim(), TestComponentAcc(), kaldi::TestIvectorExtraction(), and UnitTestFullGmm().
int32 ComputeGconsts | ( | ) |
Sets the gconsts.
Returns the number that are "invalid" e.g. because of zero weights or variances.
Definition at line 92 of file full-gmm.cc.
References FullGmm::Dim(), FullGmm::gconsts_, FullGmm::inv_covars_, SpMatrix< Real >::InvertDouble(), KALDI_ASSERT, KALDI_ERR, KALDI_ISINF, KALDI_ISNAN, kaldi::Log(), SpMatrix< Real >::LogPosDefDet(), M_LOG_2PI, FullGmm::means_invcovars_, FullGmm::NumGauss(), MatrixBase< Real >::Row(), FullGmm::valid_gconsts_, kaldi::VecSpVec(), and FullGmm::weights_.
Referenced by Sgmm2Project::ApplyProjection(), FullGmm::CopyFromDiagGmm(), FullGmm::Dim(), kaldi::unittest::InitRandFullGmm(), FullGmm::Interpolate(), main(), FullGmm::Merge(), kaldi::MergeFullGmm(), FullGmm::MergePreselect(), kaldi::MleFullGmmUpdate(), FullGmm::Perturb(), FullGmm::Read(), FullGmm::Split(), test_flags_driven_update(), UnitTestEstimateFullGmm(), and UnitTestFullGmm().
void CopyFromDiagGmm | ( | const DiagGmm & | diaggmm | ) |
Copies from given DiagGmm.
Definition at line 77 of file full-gmm.cc.
References FullGmm::ComputeGconsts(), MatrixBase< Real >::CopyFromMat(), rnnlm::d, FullGmm::Dim(), DiagGmm::Dim(), DiagGmm::gconsts(), FullGmm::gconsts_, FullGmm::inv_covars_, DiagGmm::inv_vars(), FullGmm::means_invcovars_, DiagGmm::means_invvars(), FullGmm::NumGauss(), DiagGmm::NumGauss(), FullGmm::Resize(), DiagGmm::weights(), and FullGmm::weights_.
Referenced by FullGmm::Dim(), main(), and UnitTestFullGmm().
void CopyFromFullGmm | ( | const FullGmm & | fullgmm | ) |
Copies from given FullGmm.
Definition at line 65 of file full-gmm.cc.
References MatrixBase< Real >::CopyFromMat(), FullGmm::Dim(), FullGmm::gconsts_, FullGmm::inv_covars_, FullGmm::means_invcovars_, FullGmm::NumGauss(), FullGmm::Resize(), FullGmm::valid_gconsts_, and FullGmm::weights_.
Referenced by FullGmm::Dim(), FullGmm::FullGmm(), kaldi::MergeFullGmm(), FullGmm::Split(), test_flags_driven_update(), test_io(), and UnitTestFullGmm().
|
inline |
Returns the dimensionality of the Gaussian mean vectors.
Definition at line 60 of file full-gmm.h.
References FullGmm::ComponentLogLikelihood(), FullGmm::ComponentPosteriors(), FullGmm::ComputeGconsts(), FullGmm::CopyFromDiagGmm(), FullGmm::CopyFromFullGmm(), FullGmm::GaussianSelection(), FullGmm::GaussianSelectionPreselect(), FullGmm::Interpolate(), kaldi::kGmmAll, FullGmm::LogLikelihood(), FullGmm::LogLikelihoods(), FullGmm::LogLikelihoodsPreselect(), FullGmm::means_invcovars_, FullGmm::Merge(), FullGmm::MergePreselect(), MatrixBase< Real >::NumCols(), FullGmm::Perturb(), FullGmm::Read(), FullGmm::Split(), and FullGmm::Write().
Referenced by AccumFullGmm::AccumulateFromFull(), FullGmm::ComponentLogLikelihood(), kaldi::ComputeFeatureNormalizingTransform(), FullGmm::ComputeGconsts(), Sgmm2Project::ComputeLdaStats(), FullGmm::CopyFromDiagGmm(), FullGmmNormal::CopyFromFullGmm(), FullGmm::CopyFromFullGmm(), DiagGmm::CopyFromFullGmm(), FullGmmNormal::CopyToFullGmm(), FullGmm::GetComponentMean(), FullGmm::GetCovars(), FullGmm::GetCovarsAndMeans(), GetLogLikeTest(), FullGmm::GetMeans(), AmSgmm2::InitializeFromFullGmm(), FullGmm::Interpolate(), DiagGmm::Interpolate(), FullGmm::LogLikelihoods(), FullGmm::LogLikelihoodsPreselect(), main(), FullGmm::Merge(), kaldi::MergeFullGmm(), FullGmm::MergePreselect(), kaldi::MleFullGmmUpdate(), kaldi::MlObjective(), FullGmm::Perturb(), AccumFullGmm::Resize(), FullGmm::SetInvCovars(), FullGmm::SetInvCovarsAndMeans(), FullGmm::Split(), test_flags_driven_update(), test_io(), TestComponentAcc(), UnitTestEstimateFullGmm(), and UnitTestFullGmm().
BaseFloat GaussianSelection | ( | const VectorBase< BaseFloat > & | data, |
int32 | num_gselect, | ||
std::vector< int32 > * | output | ||
) | const |
Get gaussian selection information for one frame.
Returns log-like for this frame. Output is the best "num_gselect" indices, sorted from best to worst likelihood. If "num_gselect" > NumGauss(), sets it to NumGauss().
Definition at line 637 of file full-gmm.cc.
References VectorBase< Real >::Data(), rnnlm::j, KALDI_ASSERT, kaldi::kUndefined, kaldi::LogAdd(), FullGmm::LogLikelihoods(), and FullGmm::NumGauss().
Referenced by FullGmm::Dim(), and main().
BaseFloat GaussianSelectionPreselect | ( | const VectorBase< BaseFloat > & | data, |
const std::vector< int32 > & | preselect, | ||
int32 | num_gselect, | ||
std::vector< int32 > * | output | ||
) | const |
Get gaussian selection information for one frame.
Returns log-like for this frame. Output is the best "num_gselect" indices that were preselected, sorted from best to worst likelihood. If "num_gselect" > NumGauss(), sets it to NumGauss().
Definition at line 674 of file full-gmm.cc.
References VectorBase< Real >::Data(), rnnlm::j, KALDI_ASSERT, KALDI_WARN, kaldi::LogAdd(), and FullGmm::LogLikelihoodsPreselect().
Referenced by FullGmm::Dim(), and main().
Const accessors.
Definition at line 143 of file full-gmm.h.
References FullGmm::gconsts_.
Referenced by DiagGmm::CopyFromFullGmm(), and kaldi::MlObjective().
void GetComponentMean | ( | int32 | gauss, |
VectorBase< Real > * | out | ||
) | const |
Accessor for component mean.
Definition at line 151 of file full-gmm-inl.h.
References VectorBase< Real >::AddSpVec(), SpMatrix< Real >::CopyFromSp(), VectorBase< Real >::CopyFromVec(), FullGmm::Dim(), VectorBase< Real >::Dim(), FullGmm::inv_covars_, SpMatrix< Real >::InvertDouble(), KALDI_ASSERT, FullGmm::means_invcovars_, FullGmm::NumGauss(), MatrixBase< Real >::Row(), and VectorBase< Real >::SetZero().
Referenced by FullGmm::inv_covars(), and UnitTestFullGmm().
void GetCovars | ( | std::vector< SpMatrix< Real > > * | v | ) | const |
Accessor for covariances.
Definition at line 106 of file full-gmm-inl.h.
References FullGmm::Dim(), rnnlm::i, FullGmm::inv_covars_, and KALDI_ASSERT.
Referenced by FullGmm::inv_covars(), test_flags_driven_update(), and UnitTestFullGmm().
Accessor for covariances and means.
Definition at line 132 of file full-gmm-inl.h.
References VectorBase< Real >::CopyFromVec(), FullGmm::Dim(), rnnlm::i, FullGmm::inv_covars_, KALDI_ASSERT, FullGmm::means_invcovars_, FullGmm::NumGauss(), Matrix< Real >::Resize(), and MatrixBase< Real >::Row().
Referenced by kaldi::ComputeFeatureNormalizingTransform(), FullGmm::inv_covars(), and UnitTestFullGmm().
void GetMeans | ( | Matrix< Real > * | m | ) | const |
Accessor for means.
Definition at line 118 of file full-gmm-inl.h.
References SpMatrix< Real >::CopyFromSp(), VectorBase< Real >::CopyFromVec(), FullGmm::Dim(), rnnlm::i, FullGmm::inv_covars_, SpMatrix< Real >::InvertDouble(), KALDI_ASSERT, FullGmm::means_invcovars_, FullGmm::NumGauss(), Matrix< Real >::Resize(), and MatrixBase< Real >::Row().
Referenced by DiagGmm::CopyFromFullGmm(), GetLogLikeTest(), FullGmm::inv_covars(), IvectorExtractor::IvectorExtractor(), test_flags_driven_update(), and UnitTestFullGmm().
void Interpolate | ( | BaseFloat | rho, |
const FullGmm & | source, | ||
GmmFlagsType | flags = kGmmAll |
||
) |
this = rho x source + (1-rho) x this
Definition at line 784 of file full-gmm.cc.
References FullGmm::ComputeGconsts(), FullGmm::Dim(), rnnlm::i, KALDI_ASSERT, kaldi::kGmmMeans, kaldi::kGmmVariances, kaldi::kGmmWeights, FullGmmNormal::means_, FullGmm::NumGauss(), FullGmmNormal::vars_, and FullGmmNormal::weights_.
Referenced by FullGmm::Dim().
Definition at line 146 of file full-gmm.h.
References FullGmm::inv_covars_.
Referenced by DiagGmm::CopyFromFullGmm(), GetLogLikeTest(), IvectorExtractor::IvectorExtractor(), kaldi::MergeFullGmm(), kaldi::MlObjective(), and UnitTestEstimateFullGmm().
Definition at line 151 of file full-gmm.h.
References FullGmm::GetComponentMean(), FullGmm::GetCovars(), FullGmm::GetCovarsAndMeans(), FullGmm::GetMeans(), FullGmm::inv_covars_, FullGmm::means_invcovars(), FullGmm::RemoveComponent(), FullGmm::RemoveComponents(), FullGmm::SetInvCovars(), FullGmm::SetInvCovarsAndMeans(), FullGmm::SetInvCovarsAndMeansInvCovars(), FullGmm::SetMeans(), and FullGmm::SetWeights().
BaseFloat LogLikelihood | ( | const VectorBase< BaseFloat > & | data | ) | const |
Returns the log-likelihood of a data point (vector) given the GMM.
Definition at line 582 of file full-gmm.cc.
References KALDI_ERR, KALDI_ISINF, KALDI_ISNAN, FullGmm::LogLikelihoods(), and VectorBase< Real >::LogSumExp().
Referenced by FullGmm::Dim(), main(), test_flags_driven_update(), test_io(), TestComponentAcc(), and UnitTestFullGmm().
void LogLikelihoods | ( | const VectorBase< BaseFloat > & | data, |
Vector< BaseFloat > * | loglikes | ||
) | const |
Outputs the per-component contributions to the log-likelihood.
Definition at line 591 of file full-gmm.cc.
References VectorBase< Real >::AddMatVec(), VectorBase< Real >::CopyFromVec(), FullGmm::Dim(), VectorBase< Real >::Dim(), FullGmm::gconsts_, FullGmm::inv_covars_, KALDI_ASSERT, kaldi::kNoTrans, kaldi::kUndefined, FullGmm::means_invcovars_, FullGmm::NumGauss(), Vector< Real >::Resize(), and kaldi::TraceSpSpLower().
Referenced by FullGmm::ComponentPosteriors(), FullGmm::Dim(), FullGmm::GaussianSelection(), FullGmm::LogLikelihood(), and UnitTestFullGmm().
void LogLikelihoodsPreselect | ( | const VectorBase< BaseFloat > & | data, |
const std::vector< int32 > & | indices, | ||
Vector< BaseFloat > * | loglikes | ||
) | const |
Outputs the per-component log-likelihoods of a subset of mixture components.
Note: indices.size() will equal loglikes->Dim() at output. loglikes[i] will correspond to the log-likelihood of the Gaussian indexed indices[i].
Definition at line 613 of file full-gmm.cc.
References SpMatrix< Real >::AddVec2(), FullGmm::Dim(), VectorBase< Real >::Dim(), FullGmm::gconsts_, rnnlm::i, FullGmm::inv_covars_, KALDI_ASSERT, kaldi::kUndefined, FullGmm::means_invcovars_, Vector< Real >::Resize(), MatrixBase< Real >::Row(), PackedMatrix< Real >::ScaleDiag(), kaldi::TraceSpSpLower(), and kaldi::VecVec().
Referenced by FullGmm::Dim(), FullGmm::GaussianSelectionPreselect(), main(), and UnitTestFullGmm().
Definition at line 145 of file full-gmm.h.
References FullGmm::means_invcovars_.
Referenced by FullGmm::inv_covars(), kaldi::MergeFullGmm(), kaldi::MlObjective(), and UnitTestEstimateFullGmm().
Non-const accessors.
Definition at line 150 of file full-gmm.h.
References FullGmm::means_invcovars_.
Merge the components and remember the order in which the components were merged (flat list of pairs)
Definition at line 206 of file full-gmm.cc.
References VectorBase< Real >::AddVec(), kaldi::ApproxEqual(), FullGmm::ComputeGconsts(), FullGmm::Dim(), FullGmm::gconsts_, rnnlm::i, FullGmm::inv_covars_, rnnlm::j, KALDI_ASSERT, KALDI_ERR, KALDI_WARN, FullGmm::means_invcovars_, FullGmm::MergedComponentsLogdet(), FullGmm::NumGauss(), Matrix< Real >::RemoveRow(), Matrix< Real >::Resize(), MatrixBase< Real >::Row(), VectorBase< Real >::Scale(), VectorBase< Real >::SetZero(), FullGmm::weights(), and FullGmm::weights_.
Referenced by FullGmm::Dim(), and UnitTestFullGmm().
|
private |
Definition at line 537 of file full-gmm.cc.
References SpMatrix< Real >::AddSp(), VectorBase< Real >::AddVec(), SpMatrix< Real >::AddVec2(), SpMatrix< Real >::CopyFromSp(), VectorBase< Real >::CopyFromVec(), VectorBase< Real >::Dim(), SpMatrix< Real >::LogPosDefDet(), PackedMatrix< Real >::Scale(), and VectorBase< Real >::Scale().
Referenced by FullGmm::Merge(), and FullGmm::MergePreselect().
BaseFloat MergePreselect | ( | int32 | target_components, |
const std::vector< std::pair< int32, int32 > > & | preselect_pairs | ||
) |
Merge the components and remember the order in which the components were merged (flat list of pairs); this version only considers merging pairs in "preselect_pairs" (or their descendants after merging).
This is for efficiency, for large models. Returns the delta likelihood.
Definition at line 382 of file full-gmm.cc.
References kaldi::ApproxEqual(), FullGmm::ComputeGconsts(), FullGmm::Dim(), FullGmm::gconsts_, rnnlm::i, FullGmm::inv_covars_, KALDI_ASSERT, KALDI_VLOG, KALDI_WARN, kaldi::kCopyData, FullGmm::means_invcovars_, FullGmm::MergedComponentsLogdet(), FullGmm::NumGauss(), Matrix< Real >::Resize(), MatrixBase< Real >::Row(), VectorBase< Real >::SetZero(), FullGmm::valid_gconsts_, and FullGmm::weights_.
Referenced by FullGmm::Dim().
|
inline |
Returns the number of mixture components in the GMM.
Definition at line 58 of file full-gmm.h.
References FullGmm::weights_.
Referenced by IvectorExtractorStats::AccStatsForUtterance(), AccumFullGmm::AccumulateFromFull(), kaldi::ComputeFeatureNormalizingTransform(), FullGmm::ComputeGconsts(), Sgmm2Project::ComputeLdaStats(), FullGmm::CopyFromDiagGmm(), FullGmmNormal::CopyFromFullGmm(), FullGmm::CopyFromFullGmm(), DiagGmm::CopyFromFullGmm(), FullGmmNormal::CopyToFullGmm(), FullGmm::GaussianSelection(), FullGmm::GetComponentMean(), FullGmm::GetCovarsAndMeans(), GetLogLikeTest(), FullGmm::GetMeans(), FullGmm::Interpolate(), DiagGmm::Interpolate(), IvectorExtractor::IvectorExtractor(), FullGmm::LogLikelihoods(), main(), FullGmm::Merge(), kaldi::MergeFullGmm(), FullGmm::MergePreselect(), kaldi::MleFullGmmUpdate(), kaldi::MlObjective(), FullGmm::Perturb(), FullGmm::RemoveComponent(), AccumFullGmm::Resize(), FullGmm::SetInvCovars(), FullGmm::SetInvCovarsAndMeans(), FullGmm::SetInvCovarsAndMeansInvCovars(), FullGmm::SetMeans(), FullGmm::Split(), test_flags_driven_update(), test_io(), TestComponentAcc(), kaldi::TestIvectorExtraction(), UnitTestEstimateFullGmm(), UnitTestFullGmm(), and FullGmm::Write().
void Perturb | ( | float | perturb_factor | ) |
Perturbs the component means with a random vector multiplied by the pertrub factor.
Definition at line 191 of file full-gmm.cc.
References TpMatrix< Real >::Cholesky(), FullGmm::ComputeGconsts(), FullGmm::Dim(), rnnlm::i, FullGmm::inv_covars_, kaldi::kTrans, FullGmm::means_invcovars_, VectorBase< Real >::MulTp(), FullGmm::NumGauss(), MatrixBase< Real >::Row(), and VectorBase< Real >::SetRandn().
Referenced by FullGmm::Dim().
void Read | ( | std::istream & | is, |
bool | binary | ||
) |
Definition at line 813 of file full-gmm.cc.
References FullGmm::ComputeGconsts(), kaldi::ExpectToken(), FullGmm::gconsts_, rnnlm::i, FullGmm::inv_covars_, KALDI_ERR, FullGmm::means_invcovars_, MatrixBase< Real >::NumCols(), Matrix< Real >::Read(), kaldi::ReadToken(), FullGmm::ResizeInvCovars(), and FullGmm::weights_.
Referenced by FullGmm::Dim(), main(), kaldi::operator>>(), and UnitTestFullGmm().
Mutators for single component, supports float or double Removes single component from model.
Definition at line 731 of file full-gmm.cc.
References FullGmm::gconsts_, FullGmm::inv_covars_, KALDI_ASSERT, FullGmm::means_invcovars_, FullGmm::NumGauss(), Matrix< Real >::RemoveRow(), FullGmm::valid_gconsts_, and FullGmm::weights_.
Referenced by FullGmm::inv_covars(), and FullGmm::RemoveComponents().
Removes multiple components from model; "gauss" must not have dups.
Definition at line 745 of file full-gmm.cc.
References rnnlm::i, kaldi::IsSortedAndUniq(), rnnlm::j, KALDI_ASSERT, and FullGmm::RemoveComponent().
Referenced by FullGmm::inv_covars(), and kaldi::MleFullGmmUpdate().
Resizes arrays to this dim. Does not initialize data.
Definition at line 41 of file full-gmm.cc.
References FullGmm::gconsts_, KALDI_ASSERT, FullGmm::means_invcovars_, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), Matrix< Real >::Resize(), FullGmm::ResizeInvCovars(), and FullGmm::weights_.
Referenced by Sgmm2Project::ApplyProjection(), FullGmm::CopyFromDiagGmm(), FullGmm::CopyFromFullGmm(), FullGmm::FullGmm(), kaldi::unittest::InitRandFullGmm(), kaldi::MergeFullGmm(), TestComponentAcc(), UnitTestEstimateFullGmm(), and UnitTestFullGmm().
Resizes arrays to this dim. Does not initialize data.
Definition at line 51 of file full-gmm.cc.
References rnnlm::i, FullGmm::inv_covars_, and KALDI_ASSERT.
Referenced by FullGmm::Read(), FullGmm::Resize(), and FullGmm::Split().
void SetInvCovars | ( | const std::vector< SpMatrix< Real > > & | v | ) |
Set the (inverse) covariances and recompute means_invcovars_.
Definition at line 83 of file full-gmm-inl.h.
References VectorBase< Real >::AddSpVec(), SpMatrix< Real >::CopyFromSp(), VectorBase< Real >::CopyFromVec(), FullGmm::Dim(), rnnlm::i, FullGmm::inv_covars_, SpMatrix< Real >::InvertDouble(), KALDI_ASSERT, FullGmm::means_invcovars_, FullGmm::NumGauss(), MatrixBase< Real >::Row(), and FullGmm::valid_gconsts_.
Referenced by FullGmm::inv_covars(), test_flags_driven_update(), and UnitTestFullGmm().
void SetInvCovarsAndMeans | ( | const std::vector< SpMatrix< Real > > & | invcovars, |
const Matrix< Real > & | means | ||
) |
Use SetInvCovarsAndMeans if updating both means and (inverse) covariances.
Definition at line 50 of file full-gmm-inl.h.
References VectorBase< Real >::AddSpVec(), FullGmm::Dim(), rnnlm::i, FullGmm::inv_covars_, KALDI_ASSERT, FullGmm::means_invcovars_, MatrixBase< Real >::NumCols(), FullGmm::NumGauss(), MatrixBase< Real >::NumRows(), MatrixBase< Real >::Row(), and FullGmm::valid_gconsts_.
Referenced by kaldi::unittest::InitRandFullGmm(), FullGmm::inv_covars(), main(), UnitTestEstimateFullGmm(), and UnitTestFullGmm().
void SetInvCovarsAndMeansInvCovars | ( | const std::vector< SpMatrix< Real > > & | invcovars, |
const Matrix< Real > & | means_invcovars | ||
) |
Use this if setting both, in the class's native format.
Definition at line 67 of file full-gmm-inl.h.
References MatrixBase< Real >::CopyFromMat(), rnnlm::i, FullGmm::inv_covars_, KALDI_ASSERT, FullGmm::means_invcovars_, MatrixBase< Real >::NumCols(), FullGmm::NumGauss(), MatrixBase< Real >::NumRows(), and FullGmm::valid_gconsts_.
Referenced by FullGmm::inv_covars(), and kaldi::MergeFullGmm().
void SetMeans | ( | const Matrix< Real > & | m | ) |
Use SetMeans to update only the Gaussian means (and not variances)
Definition at line 38 of file full-gmm-inl.h.
References rnnlm::i, FullGmm::inv_covars_, KALDI_ASSERT, FullGmm::means_invcovars_, MatrixBase< Real >::NumCols(), FullGmm::NumGauss(), MatrixBase< Real >::NumRows(), MatrixBase< Real >::Row(), and FullGmm::valid_gconsts_.
Referenced by FullGmm::inv_covars(), test_flags_driven_update(), and UnitTestFullGmm().
void SetWeights | ( | const Vector< Real > & | w | ) |
Mutators for both float or double.
Set mixure weights
Definition at line 31 of file full-gmm-inl.h.
References VectorBase< Real >::Dim(), KALDI_ASSERT, FullGmm::valid_gconsts_, and FullGmm::weights_.
Referenced by kaldi::unittest::InitRandFullGmm(), FullGmm::inv_covars(), main(), kaldi::MergeFullGmm(), test_flags_driven_update(), UnitTestEstimateFullGmm(), and UnitTestFullGmm().
Merge the components and remember the order in which the components were merged (flat list of pairs)
Definition at line 132 of file full-gmm.cc.
References TpMatrix< Real >::Cholesky(), FullGmm::ComputeGconsts(), FullGmm::CopyFromFullGmm(), FullGmm::Dim(), FullGmm::FullGmm(), FullGmm::gconsts_, rnnlm::i, FullGmm::inv_covars_, KALDI_WARN, kaldi::kTrans, FullGmm::means_invcovars_, VectorBase< Real >::MulTp(), FullGmm::NumGauss(), MatrixBase< Real >::Range(), Matrix< Real >::Resize(), FullGmm::ResizeInvCovars(), MatrixBase< Real >::Row(), VectorBase< Real >::SetRandn(), and FullGmm::weights_.
Referenced by FullGmm::Dim(), main(), UnitTestEstimateFullGmm(), and UnitTestFullGmm().
Definition at line 144 of file full-gmm.h.
References FullGmm::weights_.
Referenced by kaldi::ComputeFeatureNormalizingTransform(), DiagGmm::CopyFromFullGmm(), GetLogLikeTest(), IvectorExtractor::IvectorExtractor(), FullGmm::Merge(), kaldi::MergeFullGmm(), test_flags_driven_update(), UnitTestEstimateFullGmm(), and UnitTestFullGmm().
void Write | ( | std::ostream & | os, |
bool | binary | ||
) | const |
Definition at line 758 of file full-gmm.cc.
References FullGmm::gconsts_, rnnlm::i, FullGmm::inv_covars_, KALDI_ERR, FullGmm::means_invcovars_, FullGmm::NumGauss(), FullGmm::valid_gconsts_, FullGmm::weights_, MatrixBase< Real >::Write(), and kaldi::WriteToken().
Referenced by FullGmm::Dim(), main(), kaldi::operator<<(), and UnitTestFullGmm().
|
friend |
this makes it a little easier to modify the internals
Definition at line 42 of file full-gmm.h.
Equals log(weight) - 0.5 * (log det(var) + mean'*inv(var)*mean)
Definition at line 199 of file full-gmm.h.
Referenced by FullGmm::ComponentLogLikelihood(), FullGmm::ComputeGconsts(), FullGmm::CopyFromDiagGmm(), FullGmm::CopyFromFullGmm(), FullGmm::gconsts(), FullGmm::LogLikelihoods(), FullGmm::LogLikelihoodsPreselect(), FullGmm::Merge(), FullGmm::MergePreselect(), FullGmm::Read(), FullGmm::RemoveComponent(), FullGmm::Resize(), FullGmm::Split(), and FullGmm::Write().
Inverse covariances.
Definition at line 202 of file full-gmm.h.
Referenced by FullGmm::ComponentLogLikelihood(), FullGmm::ComputeGconsts(), FullGmm::CopyFromDiagGmm(), FullGmmNormal::CopyFromFullGmm(), FullGmm::CopyFromFullGmm(), FullGmmNormal::CopyToFullGmm(), FullGmm::GetComponentMean(), FullGmm::GetCovars(), FullGmm::GetCovarsAndMeans(), FullGmm::GetMeans(), FullGmm::inv_covars(), FullGmm::LogLikelihoods(), FullGmm::LogLikelihoodsPreselect(), FullGmm::Merge(), FullGmm::MergePreselect(), FullGmm::Perturb(), FullGmm::Read(), FullGmm::RemoveComponent(), FullGmm::ResizeInvCovars(), FullGmm::SetInvCovars(), FullGmm::SetInvCovarsAndMeans(), FullGmm::SetInvCovarsAndMeansInvCovars(), FullGmm::SetMeans(), FullGmm::Split(), and FullGmm::Write().
Means times inverse covariances.
Definition at line 203 of file full-gmm.h.
Referenced by FullGmm::ComponentLogLikelihood(), FullGmm::ComputeGconsts(), FullGmm::CopyFromDiagGmm(), FullGmmNormal::CopyFromFullGmm(), FullGmm::CopyFromFullGmm(), FullGmmNormal::CopyToFullGmm(), FullGmm::Dim(), FullGmm::GetComponentMean(), FullGmm::GetCovarsAndMeans(), FullGmm::GetMeans(), FullGmm::LogLikelihoods(), FullGmm::LogLikelihoodsPreselect(), FullGmm::means_invcovars(), FullGmm::Merge(), FullGmm::MergePreselect(), FullGmm::Perturb(), FullGmm::Read(), FullGmm::RemoveComponent(), FullGmm::Resize(), FullGmm::SetInvCovars(), FullGmm::SetInvCovarsAndMeans(), FullGmm::SetInvCovarsAndMeansInvCovars(), FullGmm::SetMeans(), FullGmm::Split(), and FullGmm::Write().
|
private |
Recompute gconsts_ if false.
Definition at line 200 of file full-gmm.h.
Referenced by FullGmm::ComponentLogLikelihood(), FullGmm::ComputeGconsts(), FullGmm::CopyFromFullGmm(), FullGmmNormal::CopyToFullGmm(), FullGmm::MergePreselect(), FullGmm::RemoveComponent(), FullGmm::SetInvCovars(), FullGmm::SetInvCovarsAndMeans(), FullGmm::SetInvCovarsAndMeansInvCovars(), FullGmm::SetMeans(), FullGmm::SetWeights(), and FullGmm::Write().
weights (not log).
Definition at line 201 of file full-gmm.h.
Referenced by FullGmm::ComputeGconsts(), FullGmm::CopyFromDiagGmm(), FullGmmNormal::CopyFromFullGmm(), FullGmm::CopyFromFullGmm(), FullGmmNormal::CopyToFullGmm(), FullGmm::Merge(), FullGmm::MergePreselect(), FullGmm::NumGauss(), FullGmm::Read(), FullGmm::RemoveComponent(), FullGmm::Resize(), FullGmm::SetWeights(), FullGmm::Split(), FullGmm::weights(), and FullGmm::Write().