kaldi Diagonal Gaussian Mixture Models More...
Classes | |
class | AmDiagGmm |
struct | UbmClusteringOptions |
Functions | |
AmDiagGmm () | |
~AmDiagGmm () | |
void | Init (const DiagGmm &proto, int32 num_pdfs) |
Initializes with a single "prototype" GMM. More... | |
void | AddPdf (const DiagGmm &gmm) |
Adds a GMM to the model, and increments the total number of PDFs. More... | |
void | CopyFromAmDiagGmm (const AmDiagGmm &other) |
Copies the parameters from another model. Allocates necessary memory. More... | |
void | SplitPdf (int32 idx, int32 target_components, float perturb_factor) |
void | SplitByCount (const Vector< BaseFloat > &state_occs, int32 target_components, float perturb_factor, BaseFloat power, BaseFloat min_count) |
void | MergeByCount (const Vector< BaseFloat > &state_occs, int32 target_components, BaseFloat power, BaseFloat min_count) |
int32 | ComputeGconsts () |
Sets the gconsts for all the PDFs. More... | |
BaseFloat | LogLikelihood (const int32 pdf_index, const VectorBase< BaseFloat > &data) const |
void | Read (std::istream &in_stream, bool binary) |
void | Write (std::ostream &out_stream, bool binary) const |
int32 | Dim () const |
int32 | NumPdfs () const |
int32 | NumGauss () const |
int32 | NumGaussInPdf (int32 pdf_index) const |
DiagGmm & | GetPdf (int32 pdf_index) |
Accessors. More... | |
const DiagGmm & | GetPdf (int32 pdf_index) const |
void | GetGaussianMean (int32 pdf_index, int32 gauss, VectorBase< BaseFloat > *out) const |
void | GetGaussianVariance (int32 pdf_index, int32 gauss, VectorBase< BaseFloat > *out) const |
void | SetGaussianMean (int32 pdf_index, int32 gauss_index, const VectorBase< BaseFloat > &in) |
Mutators. More... | |
void | RemovePdf (int32 pdf_index) |
KALDI_DISALLOW_COPY_AND_ASSIGN (AmDiagGmm) | |
UbmClusteringOptions () | |
UbmClusteringOptions (int32 ncomp, BaseFloat red, int32 interm_gauss, BaseFloat vfloor, int32 max_am_gauss) | |
void | Register (OptionsItf *opts) |
void | Check () |
void | ClusterGaussiansToUbm (const AmDiagGmm &am, const Vector< BaseFloat > &state_occs, UbmClusteringOptions opts, DiagGmm *ubm_out) |
Clusters the Gaussians in an acoustic model to a single GMM with specified number of components. More... | |
Variables | |
std::vector< DiagGmm * > | densities_ |
int32 | ubm_num_gauss |
BaseFloat | reduce_state_factor |
int32 | intermediate_num_gauss |
BaseFloat | cluster_varfloor |
int32 | max_am_gauss |
kaldi Diagonal Gaussian Mixture Models
void AddPdf | ( | const DiagGmm & | gmm | ) |
Adds a GMM to the model, and increments the total number of PDFs.
Definition at line 57 of file am-diag-gmm.cc.
References CopyFromDiagGmm(), AmDiagGmm::densities_, Dim(), AmDiagGmm::Dim(), and KALDI_ASSERT.
Referenced by AmDiagGmm::AmDiagGmm(), kaldi::InitAmGmm(), kaldi::InitAmGmmFromOld(), main(), UnitTestAmDiagGmm(), UnitTestMleAmDiagGmm(), UnitTestRegressionTree(), and kaldi::UnitTestRegtreeFmllrDiagGmm().
|
inline |
Definition at line 38 of file am-diag-gmm.h.
References AmDiagGmm::AddPdf(), AmDiagGmm::ComputeGconsts(), AmDiagGmm::CopyFromAmDiagGmm(), AmDiagGmm::Init(), AmDiagGmm::LogLikelihood(), AmDiagGmm::MergeByCount(), AmDiagGmm::Read(), AmDiagGmm::SplitByCount(), AmDiagGmm::SplitPdf(), AmDiagGmm::Write(), and AmDiagGmm::~AmDiagGmm().
void Check | ( | ) |
Definition at line 178 of file am-diag-gmm.cc.
References KALDI_ERR.
Referenced by kaldi::ClusterGaussiansToUbm(), and main().
void ClusterGaussiansToUbm | ( | const AmDiagGmm & | am, |
const Vector< BaseFloat > & | state_occs, | ||
UbmClusteringOptions | opts, | ||
DiagGmm * | ubm_out | ||
) |
Clusters the Gaussians in an acoustic model to a single GMM with specified number of components.
First the each state is mixed-down to a single Gaussian, then the states are clustered by clustering these Gaussians in a bottom-up fashion. Number of clusters is determined by reduce_state_factor. The Gaussians for each cluster of states are then merged based on the least likelihood reduction till there are intermediate_numcomp Gaussians, which are then merged into ubm_num_gauss Gaussians. This is the UBM initialization algorithm described in section 2.1 of Povey, et al., "The subspace Gaussian mixture model - A structured model for speech recognition", In Computer Speech and Language, April 2011.
Definition at line 195 of file am-diag-gmm.cc.
References VectorBase< Real >::AddVec2(), UbmClusteringOptions::Check(), UbmClusteringOptions::cluster_varfloor, kaldi::ClusterBottomUp(), kaldi::ClusterBottomUpCompartmentalized(), AmDiagGmm::CopyFromAmDiagGmm(), CopyFromDiagGmm(), VectorBase< Real >::CopyFromVec(), MatrixBase< Real >::CopyRowFromVec(), GaussClusterable::count(), kaldi::DeletePointers(), AmDiagGmm::Dim(), GetComponentMean(), GetComponentVariance(), AmDiagGmm::GetGaussianMean(), AmDiagGmm::GetGaussianVariance(), AmDiagGmm::GetPdf(), rnnlm::i, UbmClusteringOptions::intermediate_num_gauss, MatrixBase< Real >::InvertElements(), KALDI_ASSERT, KALDI_LOG, KALDI_VLOG, KALDI_WARN, UbmClusteringOptions::max_am_gauss, Merge(), AmDiagGmm::MergeByCount(), NumGauss(), AmDiagGmm::NumGauss(), AmDiagGmm::NumPdfs(), UbmClusteringOptions::reduce_state_factor, Resize(), MatrixBase< Real >::Row(), VectorBase< Real >::Scale(), SetInvVarsAndMeans(), SetWeights(), VectorBase< Real >::Sum(), UbmClusteringOptions::ubm_num_gauss, weights(), GaussClusterable::x2_stats(), and GaussClusterable::x_stats().
Referenced by main(), UbmClusteringOptions::Register(), and TestClustering().
int32 ComputeGconsts | ( | ) |
Sets the gconsts for all the PDFs.
Returns the total number of Gaussians over all PDFs that are "invalid" e.g. due to zero weights or variances.
Definition at line 90 of file am-diag-gmm.cc.
References AmDiagGmm::densities_, and KALDI_WARN.
Referenced by AmDiagGmm::AmDiagGmm(), kaldi::DoRescalingUpdate(), and RegtreeMllrDiagGmm::TransformModel().
void CopyFromAmDiagGmm | ( | const AmDiagGmm & | other | ) |
Copies the parameters from another model. Allocates necessary memory.
Definition at line 79 of file am-diag-gmm.cc.
References kaldi::DeletePointers(), AmDiagGmm::densities_, rnnlm::i, and AmDiagGmm::NumPdfs().
Referenced by AmDiagGmm::AmDiagGmm(), kaldi::ClusterGaussiansToUbm(), main(), TestAmDiagGmmAccsIO(), TestMllrAccsIO(), TestSplitStates(), and TestXformMean().
|
inline |
Definition at line 79 of file am-diag-gmm.h.
References AmDiagGmm::densities_.
Referenced by AmDiagGmm::AddPdf(), RegressionTree::BuildTree(), kaldi::ClusterGaussiansToUbm(), BasisFmllrEstimate::ComputeAmDiagPrecond(), DecodableAmDiagGmmRegtreeMllr::GetXformedMeanInvVars(), main(), kaldi::MapAmDiagGmmUpdate(), kaldi::MleAmDiagGmmUpdate(), TestAmDiagGmmIO(), TestMllrAccsIO(), TestSplitStates(), TestXformMean(), and AmDiagGmm::Write().
|
inline |
Definition at line 131 of file am-diag-gmm.h.
References AmDiagGmm::densities_, and KALDI_ASSERT.
Referenced by RegressionTree::BuildTree(), kaldi::ClusterGaussiansToUbm(), RegtreeMllrDiagGmm::GetTransformedMeans(), AmDiagGmm::NumPdfs(), and RegtreeMllrDiagGmm::TransformModel().
|
inline |
Definition at line 138 of file am-diag-gmm.h.
References AmDiagGmm::densities_, and KALDI_ASSERT.
Referenced by RegressionTree::BuildTree(), kaldi::ClusterGaussiansToUbm(), and AmDiagGmm::NumPdfs().
Accessors.
Definition at line 119 of file am-diag-gmm.h.
References AmDiagGmm::densities_, and KALDI_ASSERT.
Referenced by kaldi::AccStatsForUtterance(), AccumAmDiagGmm::AccumulateForGaussian(), RegtreeMllrDiagGmmAccs::AccumulateForGaussian(), RegtreeFmllrDiagGmmAccs::AccumulateForGaussian(), AccumAmDiagGmm::AccumulateForGmm(), RegtreeMllrDiagGmmAccs::AccumulateForGmm(), RegtreeFmllrDiagGmmAccs::AccumulateForGmm(), AccumAmDiagGmm::AccumulateForGmmTwofeats(), kaldi::AccumulateForUtterance(), RegressionTree::BuildTree(), kaldi::ClusterGaussiansToUbm(), BasisFmllrEstimate::ComputeAmDiagPrecond(), kaldi::ComputeAmGmmFeatureDeriv(), kaldi::DoRescalingUpdate(), SingleUtteranceGmmDecoder::EstimateFmllr(), SingleUtteranceGmmDecoder::GetGaussianPosteriors(), kaldi::GetStatsDerivative(), RegtreeMllrDiagGmm::GetTransformedMeans(), DecodableAmDiagGmmRegtreeMllr::GetXformedMeanInvVars(), AccumAmDiagGmm::Init(), kaldi::InitAmGmmFromOld(), kaldi::IsmoothStatsAmDiagGmmFromModel(), DecodableAmDiagGmmRegtreeFmllr::LogLikelihoodZeroBased(), DecodableAmDiagGmmUnmapped::LogLikelihoodZeroBased(), DecodableAmDiagGmmRegtreeMllr::LogLikelihoodZeroBased(), main(), kaldi::MapAmDiagGmmUpdate(), kaldi::MleAmDiagGmmUpdate(), AmDiagGmm::NumPdfs(), kaldi::ResizeModel(), TestXformMean(), kaldi::UpdateEbwAmDiagGmm(), and kaldi::UpdateEbwWeightsAmDiagGmm().
Initializes with a single "prototype" GMM.
Definition at line 38 of file am-diag-gmm.cc.
References kaldi::DeletePointers(), AmDiagGmm::densities_, and KALDI_WARN.
Referenced by AmDiagGmm::AmDiagGmm(), and UnitTestRegtreeMllrDiagGmm().
|
private |
|
inline |
Definition at line 108 of file am-diag-gmm.h.
References AmDiagGmm::densities_.
Referenced by AmDiagGmm::AmDiagGmm(), OnlineDecodableDiagGmmScaled::LogLikelihood(), DecodableDiagGmmScaledOnline::LogLikelihood(), main(), TestAmDiagGmmAccsIO(), TestAmDiagGmmIO(), TestMllrAccsIO(), TestSplitStates(), and TestXformMean().
void MergeByCount | ( | const Vector< BaseFloat > & | state_occs, |
int32 | target_components, | ||
BaseFloat | power, | ||
BaseFloat | min_count | ||
) |
Definition at line 125 of file am-diag-gmm.cc.
References AmDiagGmm::densities_, kaldi::GetSplitTargets(), rnnlm::i, KALDI_LOG, AmDiagGmm::NumGauss(), and AmDiagGmm::NumPdfs().
Referenced by AmDiagGmm::AmDiagGmm(), kaldi::ClusterGaussiansToUbm(), and main().
int32 NumGauss | ( | ) | const |
Definition at line 72 of file am-diag-gmm.cc.
References AmDiagGmm::densities_, and rnnlm::i.
Referenced by RegressionTree::BuildTree(), kaldi::ClusterGaussiansToUbm(), main(), RegressionTree::MakeGauss2Bclass(), AmDiagGmm::MergeByCount(), kaldi::MleAmDiagGmmUpdate(), AmDiagGmm::NumPdfs(), RegressionTree::Read(), AmDiagGmm::SplitByCount(), TestClustering(), and TestSplitStates().
Definition at line 113 of file am-diag-gmm.h.
References AmDiagGmm::densities_, and KALDI_ASSERT.
Referenced by RegressionTree::MakeGauss2Bclass(), AmDiagGmm::NumPdfs(), and kaldi::UnitTestRegtreeFmllrDiagGmm().
|
inline |
Definition at line 82 of file am-diag-gmm.h.
References AmDiagGmm::densities_, AmDiagGmm::GetGaussianMean(), AmDiagGmm::GetGaussianVariance(), AmDiagGmm::GetPdf(), AmDiagGmm::NumGauss(), AmDiagGmm::NumGaussInPdf(), and AmDiagGmm::SetGaussianMean().
Referenced by RegressionTree::BuildTree(), kaldi::ClusterGaussiansToUbm(), BasisFmllrEstimate::ComputeAmDiagPrecond(), AmDiagGmm::CopyFromAmDiagGmm(), kaldi::DoRescalingUpdate(), kaldi::GetStatsDerivative(), AccumAmDiagGmm::Init(), kaldi::InitAmGmmFromOld(), DecodableAmDiagGmmRegtreeMllr::InitCache(), kaldi::IsmoothStatsAmDiagGmmFromModel(), main(), RegressionTree::MakeGauss2Bclass(), kaldi::MapAmDiagGmmUpdate(), AmDiagGmm::MergeByCount(), kaldi::MleAmDiagGmmUpdate(), DecodableAmDiagGmmUnmapped::NumIndices(), DecodableAmDiagGmmUnmapped::ResetLogLikeCache(), kaldi::ResizeModel(), AmDiagGmm::SplitByCount(), TestAmDiagGmmAccsIO(), TestAmDiagGmmIO(), TestClustering(), TestSplitStates(), kaldi::UpdateEbwAmDiagGmm(), and kaldi::UpdateEbwWeightsAmDiagGmm().
void Read | ( | std::istream & | in_stream, |
bool | binary | ||
) |
Definition at line 147 of file am-diag-gmm.cc.
References AmDiagGmm::densities_, kaldi::ExpectToken(), rnnlm::i, KALDI_ASSERT, and kaldi::ReadBasicType().
Referenced by AmDiagGmm::AmDiagGmm(), kaldi::InitAmGmmFromOld(), main(), and TestAmDiagGmmIO().
|
inline |
Definition at line 176 of file am-diag-gmm.h.
References kaldi::ClusterGaussiansToUbm(), and OptionsItf::Register().
Referenced by main().
|
private |
|
inline |
Mutators.
Definition at line 145 of file am-diag-gmm.h.
References AmDiagGmm::densities_, and KALDI_ASSERT.
Referenced by AmDiagGmm::NumPdfs(), and RegtreeMllrDiagGmm::TransformModel().
void SplitByCount | ( | const Vector< BaseFloat > & | state_occs, |
int32 | target_components, | ||
float | perturb_factor, | ||
BaseFloat | power, | ||
BaseFloat | min_count | ||
) |
Definition at line 102 of file am-diag-gmm.cc.
References AmDiagGmm::densities_, kaldi::GetSplitTargets(), rnnlm::i, KALDI_LOG, AmDiagGmm::NumGauss(), and AmDiagGmm::NumPdfs().
Referenced by AmDiagGmm::AmDiagGmm(), main(), and TestSplitStates().
Definition at line 152 of file am-diag-gmm.h.
References AmDiagGmm::densities_, and KALDI_ASSERT.
Referenced by AmDiagGmm::AmDiagGmm(), and kaldi::UnitTestRegtreeFmllrDiagGmm().
|
inline |
Definition at line 167 of file am-diag-gmm.h.
|
inline |
Definition at line 171 of file am-diag-gmm.h.
void Write | ( | std::ostream & | out_stream, |
bool | binary | ||
) | const |
Definition at line 163 of file am-diag-gmm.cc.
References AmDiagGmm::densities_, AmDiagGmm::Dim(), KALDI_WARN, kaldi::WriteBasicType(), and kaldi::WriteToken().
Referenced by AmDiagGmm::AmDiagGmm(), main(), and TestAmDiagGmmIO().
~AmDiagGmm | ( | ) |
Definition at line 34 of file am-diag-gmm.cc.
References kaldi::DeletePointers(), and AmDiagGmm::densities_.
Referenced by AmDiagGmm::AmDiagGmm().
BaseFloat cluster_varfloor |
Definition at line 164 of file am-diag-gmm.h.
Referenced by kaldi::ClusterGaussiansToUbm().
|
private |
Definition at line 99 of file am-diag-gmm.h.
Referenced by AmDiagGmm::AddPdf(), AmDiagGmm::ComputeGconsts(), AmDiagGmm::CopyFromAmDiagGmm(), AmDiagGmm::Dim(), AmDiagGmm::GetGaussianMean(), AmDiagGmm::GetGaussianVariance(), AmDiagGmm::GetPdf(), AmDiagGmm::Init(), AmDiagGmm::LogLikelihood(), AmDiagGmm::MergeByCount(), AmDiagGmm::NumGauss(), AmDiagGmm::NumGaussInPdf(), AmDiagGmm::NumPdfs(), AmDiagGmm::Read(), AmDiagGmm::RemovePdf(), AmDiagGmm::SetGaussianMean(), AmDiagGmm::SplitByCount(), AmDiagGmm::SplitPdf(), AmDiagGmm::Write(), and AmDiagGmm::~AmDiagGmm().
int32 intermediate_num_gauss |
Definition at line 163 of file am-diag-gmm.h.
Referenced by kaldi::ClusterGaussiansToUbm().
int32 max_am_gauss |
Definition at line 165 of file am-diag-gmm.h.
Referenced by kaldi::ClusterGaussiansToUbm().
BaseFloat reduce_state_factor |
Definition at line 162 of file am-diag-gmm.h.
Referenced by kaldi::ClusterGaussiansToUbm().
int32 ubm_num_gauss |
Definition at line 161 of file am-diag-gmm.h.
Referenced by kaldi::ClusterGaussiansToUbm().