Class for definition of the subspace Gmm acoustic model. More...
#include <am-sgmm2.h>
Public Member Functions | |
AmSgmm2 () | |
void | Read (std::istream &is, bool binary) |
void | Write (std::ostream &os, bool binary, SgmmWriteFlagsType write_params) const |
void | Check (bool show_properties=true) |
Checks the various components for correct sizes. More... | |
void | InitializeFromFullGmm (const FullGmm &gmm, const std::vector< int32 > &pdf2group, int32 phn_subspace_dim, int32 spk_subspace_dim, bool speaker_dependent_weights, BaseFloat self_weight) |
Initializes the SGMM parameters from a full-covariance UBM. More... | |
void | CopyGlobalsInitVecs (const AmSgmm2 &other, const std::vector< int32 > &pdf2group, BaseFloat self_weight) |
Copies the global parameters from the supplied model, but sets the state vectors to zero. More... | |
void | CopyFromSgmm2 (const AmSgmm2 &other, bool copy_normalizers, bool copy_weights) |
Used to copy models (useful in update) More... | |
BaseFloat | GaussianSelection (const Sgmm2GselectConfig &config, const VectorBase< BaseFloat > &data, std::vector< int32 > *gselect) const |
Computes the top-scoring Gaussian indices (used for pruning of later stages of computation). More... | |
void | ComputePerFrameVars (const VectorBase< BaseFloat > &data, const std::vector< int32 > &gselect, const Sgmm2PerSpkDerivedVars &spk_vars, Sgmm2PerFrameDerivedVars *per_frame_vars) const |
This needs to be called with each new frame of data, prior to accumulation or likelihood evaluation: it computes various pre-computed quantities. More... | |
void | ComputePerSpkDerivedVars (Sgmm2PerSpkDerivedVars *vars) const |
Computes the per-speaker derived vars; assumes vars->v_s is already set up. More... | |
BaseFloat | LogLikelihood (const Sgmm2PerFrameDerivedVars &per_frame_vars, int32 j2, Sgmm2LikelihoodCache *cache, Sgmm2PerSpkDerivedVars *spk_vars, BaseFloat log_prune=0.0) const |
This does a likelihood computation for a given state using the pre-selected Gaussian components (in per_frame_vars). More... | |
BaseFloat | ComponentPosteriors (const Sgmm2PerFrameDerivedVars &per_frame_vars, int32 j2, Sgmm2PerSpkDerivedVars *spk_vars, Matrix< BaseFloat > *post) const |
Similar to LogLikelihood() function above, but also computes the posterior probabilities for the pre-selected Gaussian components and all substates. More... | |
void | SplitSubstates (const Vector< BaseFloat > &state_occupancies, const Sgmm2SplitSubstatesConfig &config) |
Increases the total number of substates based on the state occupancies. More... | |
void | IncreasePhoneSpaceDim (int32 target_dim, const Matrix< BaseFloat > &norm_xform) |
Functions for increasing the phonetic and speaker space dimensions. More... | |
void | IncreaseSpkSpaceDim (int32 target_dim, const Matrix< BaseFloat > &norm_xform, bool speaker_dependent_weights) |
Increase the subspace dimension for speakers. More... | |
void | ComputeDerivedVars () |
Computes (and initializes if necessary) derived vars... More... | |
void | ComputeNormalizers () |
Computes the data-independent terms in the log-likelihood computation for each Gaussian component and all substates. More... | |
void | ComputeWeights () |
Computes the weights w_jmi_, which is needed for likelihood evaluation with SSGMMs. More... | |
void | ComputeFmllrPreXform (const Vector< BaseFloat > &pdf_occs, Matrix< BaseFloat > *xform, Matrix< BaseFloat > *inv_xform, Vector< BaseFloat > *diag_mean_scatter) const |
Computes the LDA-like pre-transform and its inverse as well as the eigenvalues of the scatter of the means used in FMLLR estimation. More... | |
int32 | NumPdfs () const |
Various model dimensions. More... | |
int32 | NumGroups () const |
int32 | Pdf2Group (int32 j2) const |
int32 | NumSubstatesForPdf (int32 j2) const |
int32 | NumSubstatesForGroup (int32 j1) const |
int32 | NumGauss () const |
int32 | PhoneSpaceDim () const |
int32 | SpkSpaceDim () const |
int32 | FeatureDim () const |
bool | HasSpeakerDependentWeights () const |
True if doing SSGMM. More... | |
bool | HasSpeakerSpace () const |
void | RemoveSpeakerSpace () |
BaseFloat | GetDjms (int32 j1, int32 m, Sgmm2PerSpkDerivedVars *spk_vars) const |
const FullGmm & | full_ubm () const |
Accessors. More... | |
const DiagGmm & | diag_ubm () const |
template<typename Real > | |
void | GetInvCovars (int32 gauss_index, SpMatrix< Real > *out) const |
Templated accessors (used to accumulate in different precision) More... | |
template<typename Real > | |
void | GetSubstateMean (int32 j1, int32 m, int32 i, VectorBase< Real > *mean_out) const |
template<typename Real > | |
void | GetNtransSigmaInv (std::vector< Matrix< Real > > *out) const |
template<typename Real > | |
void | GetSubstateSpeakerMean (int32 j1, int32 substate, int32 gauss, const Sgmm2PerSpkDerivedVars &spk, VectorBase< Real > *mean_out) const |
template<typename Real > | |
void | GetVarScaledSubstateSpeakerMean (int32 j1, int32 substate, int32 gauss, const Sgmm2PerSpkDerivedVars &spk, VectorBase< Real > *mean_out) const |
template<class Real > | |
void | ComputeH (std::vector< SpMatrix< Real > > *H_i) const |
Computes quantities H = M_i Sigma_i^{-1} M_i^T. More... | |
Protected Attributes | |
std::vector< int32 > | pdf2group_ |
std::vector< std::vector< int32 > > | group2pdf_ |
DiagGmm | diag_ubm_ |
These contain the "background" model associated with the subspace GMM. More... | |
FullGmm | full_ubm_ |
std::vector< SpMatrix< BaseFloat > > | SigmaInv_ |
Globally shared parameters of the subspace GMM. More... | |
std::vector< Matrix< BaseFloat > > | M_ |
Phonetic-subspace projections. Dimension is [I][D][S]. More... | |
std::vector< Matrix< BaseFloat > > | N_ |
Speaker-subspace projections. Dimension is [I][D][T]. More... | |
Matrix< BaseFloat > | w_ |
Phonetic-subspace weight projection vectors. Dimension is [I][S]. More... | |
Matrix< BaseFloat > | u_ |
[SSGMM] Speaker-subspace weight projection vectors. Dimension is [I][T] More... | |
std::vector< Matrix< BaseFloat > > | v_ |
The parameters in a particular SGMM state. More... | |
std::vector< Vector< BaseFloat > > | c_ |
c_{jm}, mixture weights. Dimension is [J2][#mix] More... | |
std::vector< Matrix< BaseFloat > > | n_ |
n_{jim}, per-Gaussian normalizer. Dimension is [J1][I][#mix] More... | |
std::vector< Matrix< BaseFloat > > | w_jmi_ |
[SSGMM] w_{jmi}, dimension is [J1][#mix][I]. Computed from w_ and v_. More... | |
std::vector< Matrix< BaseFloat > > | M_prior_ |
SpMatrix< BaseFloat > | row_cov_inv_ |
SpMatrix< BaseFloat > | col_cov_inv_ |
Private Member Functions | |
void | ComputeGammaI (const Vector< BaseFloat > &state_occupancies, Vector< BaseFloat > *gamma_i) const |
Computes quasi-occupancies gamma_i from the state-level occupancies, assuming model correctness. More... | |
void | SplitSubstatesInGroup (const Vector< BaseFloat > &pdf_occupancies, const Sgmm2SplitSubstatesConfig &opts, const SpMatrix< BaseFloat > &sqrt_H_sm, int32 j1, int32 M) |
Called inside SplitSubstates(); splits substates of one group. More... | |
void | ComputeNormalizersInternal (int32 num_threads, int32 thread, int32 *entropy_count, double *entropy_sum) |
Compute a subset of normalizers; used in multi-threaded implementation. More... | |
void | ComponentLogLikes (const Sgmm2PerFrameDerivedVars &per_frame_vars, int32 j1, Sgmm2PerSpkDerivedVars *spk_vars, Matrix< BaseFloat > *loglikes) const |
The code below is called internally from LogLikelihood() and ComponentPosteriors(). More... | |
void | InitializeMw (int32 phn_subspace_dim, const Matrix< BaseFloat > &norm_xform) |
Initializes the matrices M_ and w_. More... | |
void | InitializeNu (int32 spk_subspace_dim, const Matrix< BaseFloat > &norm_xform, bool speaker_dependent_weights) |
Initializes the matrices N_ and [if speaker_dependent_weights==true] u_. More... | |
void | InitializeVecsAndSubstateWeights (BaseFloat self_weight) |
void | InitializeCovars () |
initializes the within-class covariances. More... | |
void | ComputeHsmFromModel (const std::vector< SpMatrix< BaseFloat > > &H, const Vector< BaseFloat > &state_occupancies, SpMatrix< BaseFloat > *H_sm, BaseFloat max_cond) const |
void | ComputePdfMappings () |
KALDI_DISALLOW_COPY_AND_ASSIGN (AmSgmm2) | |
maps from each pdf (index j2) to the corresponding group of pdfs (index j1) for SCTM. More... | |
Friends | |
class | ComputeNormalizersClass |
class | Sgmm2Project |
class | EbwAmSgmm2Updater |
class | MleAmSgmm2Accs |
class | MleAmSgmm2Updater |
class | MleSgmm2SpeakerAccs |
class | AmSgmm2Functions |
class | Sgmm2Feature |
Class for definition of the subspace Gmm acoustic model.
Definition at line 231 of file am-sgmm2.h.
|
inline |
Definition at line 233 of file am-sgmm2.h.
void Check | ( | bool | show_properties = true | ) |
Checks the various components for correct sizes.
With wrong sizes, assertion failure occurs. When the argument is set to true, dimensions of the various components are printed.
Definition at line 276 of file am-sgmm2.cc.
References rnnlm::i, KALDI_ASSERT, and KALDI_LOG.
Referenced by TestSgmm2IO(), and TestSgmm2Substates().
|
inlineprivate |
The code below is called internally from LogLikelihood() and ComponentPosteriors().
It computes the per-Gaussian log-likelihods given each sub-state of the state. Note: the mixture weights are not included at this point.
Definition at line 476 of file am-sgmm2.cc.
References VectorBase< Real >::Add(), VectorBase< Real >::AddMatVec(), VectorBase< Real >::AddVec(), MatrixBase< Real >::AddVecToRows(), VectorBase< Real >::ApplyLog(), Sgmm2PerSpkDerivedVars::b_is, VectorBase< Real >::Dim(), Sgmm2PerFrameDerivedVars::gselect, rnnlm::i, KALDI_ASSERT, kaldi::kNoTrans, Sgmm2PerSpkDerivedVars::log_d_jms, Sgmm2PerFrameDerivedVars::nti, Vector< Real >::Resize(), Matrix< Real >::Resize(), MatrixBase< Real >::Row(), Sgmm2PerSpkDerivedVars::v_s, and Sgmm2PerFrameDerivedVars::zti.
BaseFloat ComponentPosteriors | ( | const Sgmm2PerFrameDerivedVars & | per_frame_vars, |
int32 | j2, | ||
Sgmm2PerSpkDerivedVars * | spk_vars, | ||
Matrix< BaseFloat > * | post | ||
) | const |
Similar to LogLikelihood() function above, but also computes the posterior probabilities for the pre-selected Gaussian components and all substates.
This one doesn't use caching to share computation for the groups of pdfs. [it's less necessary, as most of the time we're doing this from alignments, or lattices that are quite sparse, so we save little by sharing this.]
Definition at line 574 of file am-sgmm2.cc.
References MatrixBase< Real >::Add(), MatrixBase< Real >::ApplyExp(), KALDI_ASSERT, kaldi::Log(), MatrixBase< Real >::Max(), MatrixBase< Real >::MulColsVec(), MatrixBase< Real >::Scale(), and MatrixBase< Real >::Sum().
Referenced by FmllrSgmm2Accs::Accumulate(), MleAmSgmm2Accs::Accumulate(), MleSgmm2SpeakerAccs::Accumulate(), kaldi::AccumulateForUtterance(), and main().
void ComputeDerivedVars | ( | ) |
Computes (and initializes if necessary) derived vars...
for now this is just the normalizers "n" and the diagonal UBM, and if we have the "u" matrix set up, also the w_jmi_ quantities.
Definition at line 810 of file am-sgmm2.cc.
Referenced by main(), TestSgmm2AccsIO(), and UnitTestEstimateSgmm2().
void ComputeFmllrPreXform | ( | const Vector< BaseFloat > & | pdf_occs, |
Matrix< BaseFloat > * | xform, | ||
Matrix< BaseFloat > * | inv_xform, | ||
Vector< BaseFloat > * | diag_mean_scatter | ||
) | const |
Computes the LDA-like pre-transform and its inverse as well as the eigenvalues of the scatter of the means used in FMLLR estimation.
Definition at line 965 of file am-sgmm2.cc.
References SpMatrix< Real >::AddMat2Sp(), MatrixBase< Real >::AddMatMat(), VectorBase< Real >::AddMatVec(), VectorBase< Real >::AddVec(), SpMatrix< Real >::AddVec2(), VectorBase< Real >::ApplyFloor(), VectorBase< Real >::ApplySoftMax(), TpMatrix< Real >::Cholesky(), MatrixBase< Real >::CopyFromMat(), MatrixBase< Real >::CopyFromTp(), VectorBase< Real >::Dim(), SpMatrix< Real >::Eig(), rnnlm::i, TpMatrix< Real >::InvertDouble(), SpMatrix< Real >::InvertDouble(), SpMatrix< Real >::IsDiagonal(), SpMatrix< Real >::IsUnit(), KALDI_ASSERT, KALDI_WARN, kaldi::kNoTrans, kaldi::kSetZero, kaldi::kTrans, kaldi::kUndefined, rnnlm::n, MatrixBase< Real >::Range(), Vector< Real >::Resize(), Matrix< Real >::Resize(), MatrixBase< Real >::Row(), VectorBase< Real >::Scale(), MatrixBase< Real >::SetUnit(), and VectorBase< Real >::Sum().
Referenced by Sgmm2FmllrGlobalParams::Init(), main(), TestSgmm2FmllrAccsIO(), TestSgmm2FmllrSubspace(), and TestSgmm2PreXform().
|
private |
Computes quasi-occupancies gamma_i from the state-level occupancies, assuming model correctness.
Definition at line 50 of file am-sgmm2.cc.
References VectorBase< Real >::AddVec(), VectorBase< Real >::Dim(), rnnlm::i, KALDI_ASSERT, kaldi::kNoTrans, and Vector< Real >::Resize().
template void ComputeH | ( | std::vector< SpMatrix< Real > > * | H_i | ) | const |
Computes quantities H = M_i Sigma_i^{-1} M_i^T.
Definition at line 1107 of file am-sgmm2.cc.
References SpMatrix< Real >::AddMat2Sp(), rnnlm::i, KALDI_ASSERT, and kaldi::kTrans.
Referenced by EbwAmSgmm2Updater::Update(), and MleAmSgmm2Updater::Update().
|
private |
Definition at line 1260 of file am-sgmm2.cc.
References SpMatrix< Real >::AddSp(), VectorBase< Real >::Dim(), rnnlm::i, KALDI_ASSERT, KALDI_LOG, KALDI_WARN, SpMatrix< Real >::LimitCondDouble(), SpMatrix< Real >::Resize(), PackedMatrix< Real >::Scale(), PackedMatrix< Real >::SetUnit(), and PackedMatrix< Real >::SetZero().
void ComputeNormalizers | ( | ) |
Computes the data-independent terms in the log-likelihood computation for each Gaussian component and all substates.
Eq. (31)
Definition at line 857 of file am-sgmm2.cc.
References kaldi::Exp(), KALDI_LOG, and kaldi::RunMultiThreaded().
Referenced by main(), TestSgmm2Fmllr(), TestSgmm2Init(), TestSgmm2Substates(), UnitTestEstimateSgmm2(), UnitTestSgmm2(), and EbwAmSgmm2Updater::Update().
|
private |
Compute a subset of normalizers; used in multi-threaded implementation.
Definition at line 873 of file am-sgmm2.cc.
References MatrixBase< Real >::AddMatMat(), MatrixBase< Real >::AddMatSp(), kaldi::Exp(), rnnlm::i, KALDI_ISFINITE, KALDI_LOG, KALDI_WARN, kaldi::kNoTrans, kaldi::kTrans, kaldi::Log(), M_PI, MatrixBase< Real >::Row(), and kaldi::VecVec().
|
private |
Definition at line 72 of file am-sgmm2.cc.
References KALDI_ASSERT, and KALDI_WARN.
void ComputePerFrameVars | ( | const VectorBase< BaseFloat > & | data, |
const std::vector< int32 > & | gselect, | ||
const Sgmm2PerSpkDerivedVars & | spk_vars, | ||
Sgmm2PerFrameDerivedVars * | per_frame_vars | ||
) | const |
This needs to be called with each new frame of data, prior to accumulation or likelihood evaluation: it computes various pre-computed quantities.
Definition at line 442 of file am-sgmm2.cc.
References VectorBase< Real >::AddSpVec(), Sgmm2PerFrameDerivedVars::gselect, rnnlm::i, KALDI_ASSERT, kaldi::kTrans, Sgmm2PerSpkDerivedVars::log_b_is, Sgmm2PerFrameDerivedVars::nti, Sgmm2PerSpkDerivedVars::o_s, Sgmm2PerFrameDerivedVars::Resize(), MatrixBase< Real >::Row(), Sgmm2PerSpkDerivedVars::v_s, kaldi::VecVec(), Sgmm2PerFrameDerivedVars::xt, Sgmm2PerFrameDerivedVars::xti, and Sgmm2PerFrameDerivedVars::zti.
Referenced by kaldi::AccumulateForUtterance(), DecodableAmSgmm2::LogLikelihoodForPdf(), main(), TestSgmm2AccsIO(), TestSgmm2FmllrAccsIO(), TestSgmm2FmllrSubspace(), TestSgmm2IncreaseDim(), TestSgmm2Init(), TestSgmm2IO(), and TestSgmm2Substates().
void ComputePerSpkDerivedVars | ( | Sgmm2PerSpkDerivedVars * | vars | ) | const |
Computes the per-speaker derived vars; assumes vars->v_s is already set up.
Definition at line 1369 of file am-sgmm2.cc.
References Sgmm2PerSpkDerivedVars::b_is, Sgmm2PerSpkDerivedVars::Clear(), rnnlm::i, KALDI_ASSERT, KALDI_WARN, kaldi::kNoTrans, Sgmm2PerSpkDerivedVars::log_b_is, Sgmm2PerSpkDerivedVars::log_d_jms, Sgmm2PerSpkDerivedVars::o_s, Matrix< Real >::Resize(), MatrixBase< Real >::Row(), and Sgmm2PerSpkDerivedVars::v_s.
Referenced by main(), and kaldi::ProcessUtterance().
void ComputeWeights | ( | ) |
Computes the weights w_jmi_, which is needed for likelihood evaluation with SSGMMs.
Definition at line 796 of file am-sgmm2.cc.
References rnnlm::i, kaldi::kNoTrans, and kaldi::kTrans.
Referenced by TestSgmm2Init(), and TestSgmm2Substates().
Used to copy models (useful in update)
Definition at line 415 of file am-sgmm2.cc.
References AmSgmm2::c_, AmSgmm2::diag_ubm_, AmSgmm2::full_ubm_, AmSgmm2::group2pdf_, KALDI_LOG, AmSgmm2::M_, AmSgmm2::N_, AmSgmm2::n_, AmSgmm2::pdf2group_, AmSgmm2::SigmaInv_, AmSgmm2::u_, AmSgmm2::v_, AmSgmm2::w_, and AmSgmm2::w_jmi_.
Referenced by TestSgmm2AccsIO(), TestSgmm2Init(), and TestSgmm2Substates().
void CopyGlobalsInitVecs | ( | const AmSgmm2 & | other, |
const std::vector< int32 > & | pdf2group, | ||
BaseFloat | self_weight | ||
) |
Copies the global parameters from the supplied model, but sets the state vectors to zero.
Definition at line 1183 of file am-sgmm2.cc.
References AmSgmm2::diag_ubm_, AmSgmm2::full_ubm_, KALDI_LOG, AmSgmm2::M_, AmSgmm2::N_, AmSgmm2::SigmaInv_, AmSgmm2::u_, and AmSgmm2::w_.
Referenced by main().
|
inline |
Definition at line 379 of file am-sgmm2.h.
References rnnlm::i.
|
inline |
Definition at line 363 of file am-sgmm2.h.
Referenced by FmllrSgmm2Accs::AccumulateForFmllrSubspace(), MleSgmm2SpeakerAccs::AccumulateFromPosteriors(), Sgmm2Project::ApplyProjection(), kaldi::CalcFmllrStepSize(), MleAmSgmm2Accs::Check(), MleAmSgmm2Updater::ComputeMPrior(), Sgmm2Project::ComputeProjection(), FmllrSgmm2Accs::FmllrObjGradient(), main(), MleAmSgmm2Updater::MapUpdateM(), MleAmSgmm2Accs::ResizeAccumulators(), TestSgmm2AccsIO(), TestSgmm2FmllrAccsIO(), TestSgmm2FmllrSubspace(), TestSgmm2IncreaseDim(), TestSgmm2Init(), TestSgmm2IO(), TestSgmm2Substates(), and EbwAmSgmm2Updater::UpdateM().
|
inline |
Accessors.
Definition at line 378 of file am-sgmm2.h.
Referenced by Sgmm2Project::ComputeProjection(), main(), TestSgmm2IncreaseDim(), and TestSgmm2Init().
BaseFloat GaussianSelection | ( | const Sgmm2GselectConfig & | config, |
const VectorBase< BaseFloat > & | data, | ||
std::vector< int32 > * | gselect | ||
) | const |
Computes the top-scoring Gaussian indices (used for pruning of later stages of computation).
Returns frame log-likelihood given selected Gaussians from full UBM.
Definition at line 1406 of file am-sgmm2.cc.
References VectorBase< Real >::Data(), Sgmm2GselectConfig::diag_gmm_nbest, VectorBase< Real >::Dim(), Sgmm2GselectConfig::full_gmm_nbest, rnnlm::i, and KALDI_ASSERT.
Referenced by main(), TestSgmm2AccsIO(), TestSgmm2FmllrAccsIO(), TestSgmm2FmllrSubspace(), TestSgmm2IncreaseDim(), TestSgmm2Init(), TestSgmm2IO(), and TestSgmm2Substates().
BaseFloat GetDjms | ( | int32 | j1, |
int32 | m, | ||
Sgmm2PerSpkDerivedVars * | spk_vars | ||
) | const |
Definition at line 948 of file am-sgmm2.cc.
References Sgmm2PerSpkDerivedVars::b_is, kaldi::Exp(), KALDI_ASSERT, kaldi::kNoTrans, and Sgmm2PerSpkDerivedVars::log_d_jms.
Referenced by MleAmSgmm2Accs::AccumulateFromPosteriors(), and MleSgmm2SpeakerAccs::AccumulateFromPosteriors().
Templated accessors (used to accumulate in different precision)
Definition at line 511 of file am-sgmm2.h.
References SpMatrix< Real >::CopyFromSp(), kaldi::kUndefined, and SpMatrix< Real >::Resize().
Referenced by kaldi::CalcFmllrStepSize(), and FmllrSgmm2Accs::FmllrObjGradient().
template void GetNtransSigmaInv | ( | std::vector< Matrix< Real > > * | out | ) | const |
Definition at line 1084 of file am-sgmm2.cc.
References MatrixBase< Real >::CopyFromMat(), MatrixBase< Real >::CopyFromSp(), rnnlm::i, KALDI_ASSERT, kaldi::kNoTrans, and kaldi::kTrans.
Referenced by MleSgmm2SpeakerAccs::MleSgmm2SpeakerAccs().
|
inline |
Definition at line 519 of file am-sgmm2.h.
References VectorBase< Real >::CopyFromVec(), VectorBase< Real >::Dim(), KALDI_ASSERT, and kaldi::kNoTrans.
Referenced by MleAmSgmm2Accs::AccumulateFromPosteriors(), and MleSgmm2SpeakerAccs::AccumulateFromPosteriors().
|
inline |
Definition at line 532 of file am-sgmm2.h.
References VectorBase< Real >::AddVec(), Sgmm2PerSpkDerivedVars::o_s, MatrixBase< Real >::Row(), and Sgmm2PerSpkDerivedVars::v_s.
void GetVarScaledSubstateSpeakerMean | ( | int32 | j1, |
int32 | substate, | ||
int32 | gauss, | ||
const Sgmm2PerSpkDerivedVars & | spk, | ||
VectorBase< Real > * | mean_out | ||
) | const |
Definition at line 541 of file am-sgmm2.h.
References kaldi::ComputeFeatureNormalizingTransform(), VectorBase< Real >::CopyFromVec(), and VectorBase< Real >::Dim().
Referenced by FmllrSgmm2Accs::AccumulateFromPosteriors().
|
inline |
True if doing SSGMM.
Definition at line 366 of file am-sgmm2.h.
Referenced by main(), MleSgmm2SpeakerAccs::MleSgmm2SpeakerAccs(), MleAmSgmm2Accs::ResizeAccumulators(), and EbwAmSgmm2Updater::UpdateW().
|
inline |
Definition at line 368 of file am-sgmm2.h.
Referenced by main().
Functions for increasing the phonetic and speaker space dimensions.
The argument norm_xform is a LDA-like feature normalizing transform, computed by the ComputeFeatureNormalizingTransform function.
Definition at line 699 of file am-sgmm2.cc.
References MatrixBase< Real >::CopyFromMat(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, KALDI_LOG, KALDI_WARN, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), MatrixBase< Real >::Range(), and Matrix< Real >::Resize().
Referenced by main().
void IncreaseSpkSpaceDim | ( | int32 | target_dim, |
const Matrix< BaseFloat > & | norm_xform, | ||
bool | speaker_dependent_weights | ||
) |
Increase the subspace dimension for speakers.
The boolean "speaker_dependent_weights" argument (for SSGMM) only makes a difference if increasing the subspace dimension from zero.
Definition at line 747 of file am-sgmm2.cc.
References MatrixBase< Real >::CopyFromMat(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, KALDI_LOG, KALDI_WARN, kaldi::kCopyData, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), and MatrixBase< Real >::Range().
Referenced by main().
|
private |
initializes the within-class covariances.
Definition at line 1248 of file am-sgmm2.cc.
References rnnlm::i.
void InitializeFromFullGmm | ( | const FullGmm & | gmm, |
const std::vector< int32 > & | pdf2group, | ||
int32 | phn_subspace_dim, | ||
int32 | spk_subspace_dim, | ||
bool | speaker_dependent_weights, | ||
BaseFloat | self_weight | ||
) |
Initializes the SGMM parameters from a full-covariance UBM.
The state2group vector maps from a state to the corresponding cluster of states [i.e. j2 to j1]. For conventionally structured systems (no 2-level tree), this can just be [ 0 1 ... n-1 ].
Definition at line 381 of file am-sgmm2.cc.
References kaldi::ComputeFeatureNormalizingTransform(), FullGmm::Dim(), KALDI_ASSERT, KALDI_LOG, and KALDI_WARN.
Referenced by main(), TestSgmm2Fmllr(), TestSgmm2Init(), UnitTestEstimateSgmm2(), and UnitTestSgmm2().
Initializes the matrices M_ and w_.
Definition at line 1126 of file am-sgmm2.cc.
References MatrixBase< Real >::CopyColFromVec(), rnnlm::i, KALDI_ASSERT, kaldi::kNoTrans, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), MatrixBase< Real >::Range(), and Matrix< Real >::Resize().
|
private |
Initializes the matrices N_ and [if speaker_dependent_weights==true] u_.
Definition at line 1155 of file am-sgmm2.cc.
References rnnlm::i, kaldi::kNoTrans, and MatrixBase< Real >::Range().
|
private |
Definition at line 1207 of file am-sgmm2.cc.
References KALDI_ASSERT.
|
private |
maps from each pdf (index j2) to the corresponding group of pdfs (index j1) for SCTM.
BaseFloat LogLikelihood | ( | const Sgmm2PerFrameDerivedVars & | per_frame_vars, |
int32 | j2, | ||
Sgmm2LikelihoodCache * | cache, | ||
Sgmm2PerSpkDerivedVars * | spk_vars, | ||
BaseFloat | log_prune = 0.0 |
||
) | const |
This does a likelihood computation for a given state using the pre-selected Gaussian components (in per_frame_vars).
If the log_prune parameter is nonzero (e.g. 5.0), the LogSumExp() stage is pruned, which is a significant speedup... smaller values are faster. Note: you have to call cache->NextFrame() before calling this for a new frame of data.
Definition at line 517 of file am-sgmm2.cc.
References MatrixBase< Real >::Add(), MatrixBase< Real >::ApplyExp(), kaldi::ApproxEqual(), KALDI_ASSERT, Sgmm2LikelihoodCache::SubstateCacheElement::likes, kaldi::Log(), Sgmm2LikelihoodCache::PdfCacheElement::log_like, MatrixBase< Real >::Max(), MatrixBase< Real >::NumCols(), Sgmm2LikelihoodCache::pdf_cache, kaldi::Rand(), Sgmm2LikelihoodCache::SubstateCacheElement::remaining_log_like, Sgmm2LikelihoodCache::substate_cache, Sgmm2LikelihoodCache::SubstateCacheElement::t, Sgmm2LikelihoodCache::PdfCacheElement::t, Sgmm2LikelihoodCache::t, and kaldi::VecVec().
Referenced by DecodableAmSgmm2::LogLikelihoodForPdf(), TestSgmm2AccsIO(), TestSgmm2FmllrAccsIO(), TestSgmm2IncreaseDim(), TestSgmm2Init(), TestSgmm2IO(), and TestSgmm2Substates().
|
inline |
Definition at line 360 of file am-sgmm2.h.
Referenced by Sgmm2Project::ApplyProjection(), kaldi::CalcFmllrStepSize(), MleAmSgmm2Accs::Check(), MleAmSgmm2Updater::ComputeMPrior(), FmllrSgmm2Accs::FmllrObjGradient(), main(), MleAmSgmm2Updater::MapUpdateM(), MleSgmm2SpeakerAccs::MleSgmm2SpeakerAccs(), MleAmSgmm2Accs::ResizeAccumulators(), TestSgmm2AccsIO(), TestSgmm2FmllrAccsIO(), TestSgmm2FmllrSubspace(), TestSgmm2IncreaseDim(), TestSgmm2Init(), TestSgmm2IO(), TestSgmm2Substates(), and EbwAmSgmm2Updater::UpdateM().
|
inline |
Definition at line 351 of file am-sgmm2.h.
Referenced by MleAmSgmm2Accs::Check(), main(), MleAmSgmm2Accs::ResizeAccumulators(), TestSgmm2AccsIO(), TestSgmm2FmllrAccsIO(), TestSgmm2IncreaseDim(), TestSgmm2Init(), TestSgmm2IO(), and TestSgmm2Substates().
|
inline |
Various model dimensions.
Definition at line 350 of file am-sgmm2.h.
Referenced by MleAmSgmm2Accs::Check(), main(), MleAmSgmm2Accs::ResizeAccumulators(), TestSgmm2AccsIO(), TestSgmm2FmllrAccsIO(), TestSgmm2FmllrSubspace(), TestSgmm2IncreaseDim(), TestSgmm2Init(), TestSgmm2IO(), TestSgmm2PreXform(), and TestSgmm2Substates().
Definition at line 357 of file am-sgmm2.h.
References KALDI_ASSERT.
Referenced by FmllrSgmm2Accs::AccumulateFromPosteriors(), MleAmSgmm2Accs::AccumulateFromPosteriors(), MleAmSgmm2Accs::Check(), MleAmSgmm2Updater::ComputeQ(), MleAmSgmm2Updater::ComputeSMeans(), main(), MleAmSgmm2Updater::RenormalizeV(), MleAmSgmm2Accs::ResizeAccumulators(), EbwAmSgmm2Updater::UpdatePhoneVectorsInternal(), MleAmSgmm2Updater::UpdatePhoneVectorsInternal(), MleAmSgmm2Updater::UpdateW(), and MleAmSgmm2Updater::UpdateWGetStats().
Definition at line 354 of file am-sgmm2.h.
References KALDI_ASSERT.
Referenced by MleSgmm2SpeakerAccs::AccumulateFromPosteriors(), MleAmSgmm2Accs::Check(), main(), MleAmSgmm2Accs::ResizeAccumulators(), EbwAmSgmm2Updater::UpdateSubstateWeights(), and MleAmSgmm2Updater::UpdateSubstateWeights().
Definition at line 196 of file am-sgmm2.cc.
References KALDI_ASSERT.
Referenced by FmllrSgmm2Accs::AccumulateFromPosteriors(), MleAmSgmm2Accs::AccumulateFromPosteriors(), MleSgmm2SpeakerAccs::AccumulateFromPosteriors(), and TestSgmm2Init().
|
inline |
Definition at line 361 of file am-sgmm2.h.
Referenced by MleAmSgmm2Accs::Check(), MleAmSgmm2Updater::ComputeMPrior(), main(), MleAmSgmm2Updater::MapUpdateM(), MleAmSgmm2Accs::ResizeAccumulators(), TestSgmm2AccsIO(), TestSgmm2FmllrAccsIO(), TestSgmm2FmllrSubspace(), TestSgmm2IncreaseDim(), TestSgmm2Init(), TestSgmm2IO(), and EbwAmSgmm2Updater::UpdateM().
void Read | ( | std::istream & | is, |
bool | binary | ||
) |
Definition at line 89 of file am-sgmm2.cc.
References kaldi::ExpectToken(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, KALDI_WARN, kaldi::ReadBasicType(), kaldi::ReadIntegerVector(), and kaldi::ReadToken().
Referenced by main(), and TestSgmm2IO().
|
inline |
Definition at line 370 of file am-sgmm2.h.
Referenced by main().
|
inline |
Definition at line 362 of file am-sgmm2.h.
Referenced by MleSgmm2SpeakerAccs::AccumulateFromPosteriors(), MleAmSgmm2Accs::Check(), main(), MleSgmm2SpeakerAccs::MleSgmm2SpeakerAccs(), MleAmSgmm2Accs::ResizeAccumulators(), and TestSgmm2Init().
void SplitSubstates | ( | const Vector< BaseFloat > & | state_occupancies, |
const Sgmm2SplitSubstatesConfig & | config | ||
) |
Increases the total number of substates based on the state occupancies.
Definition at line 657 of file am-sgmm2.cc.
References SpMatrix< Real >::ApplyPow(), VectorBase< Real >::Dim(), kaldi::GetSplitTargets(), KALDI_ASSERT, KALDI_LOG, Sgmm2SplitSubstatesConfig::max_cond, Sgmm2SplitSubstatesConfig::min_count, Sgmm2SplitSubstatesConfig::power, and Sgmm2SplitSubstatesConfig::split_substates.
Referenced by main(), and TestSgmm2Substates().
|
private |
Called inside SplitSubstates(); splits substates of one group.
Definition at line 599 of file am-sgmm2.cc.
References kaldi::_RandGauss(), VectorBase< Real >::AddRowSumMat(), VectorBase< Real >::AddSpVec(), VectorBase< Real >::Data(), rnnlm::i, KALDI_ASSERT, Sgmm2SplitSubstatesConfig::perturb_factor, and MatrixBase< Real >::Row().
void Write | ( | std::ostream & | os, |
bool | binary, | ||
SgmmWriteFlagsType | write_params | ||
) | const |
Definition at line 203 of file am-sgmm2.cc.
References rnnlm::i, KALDI_WARN, kaldi::kSgmmBackgroundGmms, kaldi::kSgmmGlobalParams, kaldi::kSgmmNormalizers, kaldi::kSgmmStateParams, kaldi::WriteBasicType(), kaldi::WriteIntegerVector(), and kaldi::WriteToken().
Referenced by main(), TestSgmm2AccsIO(), and TestSgmm2IO().
|
friend |
Definition at line 506 of file am-sgmm2.h.
|
friend |
Definition at line 500 of file am-sgmm2.h.
|
friend |
Definition at line 502 of file am-sgmm2.h.
|
friend |
Definition at line 503 of file am-sgmm2.h.
|
friend |
Definition at line 504 of file am-sgmm2.h.
|
friend |
Definition at line 505 of file am-sgmm2.h.
|
friend |
Definition at line 507 of file am-sgmm2.h.
|
friend |
Definition at line 501 of file am-sgmm2.h.
c_{jm}, mixture weights. Dimension is [J2][#mix]
Definition at line 438 of file am-sgmm2.h.
Referenced by AmSgmm2::CopyFromSgmm2(), EbwAmSgmm2Updater::UpdateSubstateWeights(), and MleAmSgmm2Updater::UpdateSubstateWeights().
Definition at line 451 of file am-sgmm2.h.
Referenced by MleAmSgmm2Updater::ComputeMPrior(), and MleAmSgmm2Updater::MapUpdateM().
|
protected |
These contain the "background" model associated with the subspace GMM.
Definition at line 413 of file am-sgmm2.h.
Referenced by Sgmm2Project::ApplyProjection(), AmSgmm2::CopyFromSgmm2(), and AmSgmm2::CopyGlobalsInitVecs().
|
protected |
Definition at line 414 of file am-sgmm2.h.
Referenced by Sgmm2Project::ApplyProjection(), AmSgmm2::CopyFromSgmm2(), and AmSgmm2::CopyGlobalsInitVecs().
|
protected |
Definition at line 410 of file am-sgmm2.h.
Referenced by AmSgmm2::CopyFromSgmm2().
Phonetic-subspace projections. Dimension is [I][D][S].
Definition at line 425 of file am-sgmm2.h.
Referenced by Sgmm2Project::ApplyProjection(), MleAmSgmm2Updater::ComputeMPrior(), MleAmSgmm2Updater::ComputeSMeans(), AmSgmm2::CopyFromSgmm2(), AmSgmm2::CopyGlobalsInitVecs(), MleAmSgmm2Updater::MapUpdateM(), MleAmSgmm2Updater::RenormalizeV(), EbwAmSgmm2Updater::UpdateM(), and MleAmSgmm2Updater::UpdateM().
Definition at line 449 of file am-sgmm2.h.
Referenced by MleAmSgmm2Updater::ComputeMPrior(), and MleAmSgmm2Updater::MapUpdateM().
Speaker-subspace projections. Dimension is [I][D][T].
Definition at line 427 of file am-sgmm2.h.
Referenced by Sgmm2Project::ApplyProjection(), AmSgmm2::CopyFromSgmm2(), AmSgmm2::CopyGlobalsInitVecs(), MleSgmm2SpeakerAccs::MleSgmm2SpeakerAccs(), MleAmSgmm2Updater::RenormalizeN(), EbwAmSgmm2Updater::UpdateN(), and MleAmSgmm2Updater::UpdateN().
n_{jim}, per-Gaussian normalizer. Dimension is [J1][I][#mix]
Definition at line 440 of file am-sgmm2.h.
Referenced by Sgmm2Project::ApplyProjection(), AmSgmm2::CopyFromSgmm2(), and MleAmSgmm2Updater::Update().
|
protected |
Definition at line 409 of file am-sgmm2.h.
Referenced by AmSgmm2::CopyFromSgmm2().
Definition at line 450 of file am-sgmm2.h.
Referenced by MleAmSgmm2Updater::ComputeMPrior(), and MleAmSgmm2Updater::MapUpdateM().
Globally shared parameters of the subspace GMM.
The various quantities are: I = number of Gaussians, D = data dimension, S = phonetic subspace dimension, T = speaker subspace dimension, J2 = number of pdfs, J1 = number of groups of pdfs (for SCTM), #mix = number of substates [of state j2 or state-group j1, depending on context]. Inverse within-class (full) covariances; dim is [I][D][D].
Definition at line 423 of file am-sgmm2.h.
Referenced by Sgmm2Project::ApplyProjection(), AmSgmm2::CopyFromSgmm2(), AmSgmm2::CopyGlobalsInitVecs(), MleAmSgmm2Updater::MapUpdateM(), MleSgmm2SpeakerAccs::MleSgmm2SpeakerAccs(), EbwAmSgmm2Updater::UpdateM(), MleAmSgmm2Updater::UpdateM(), EbwAmSgmm2Updater::UpdateN(), MleAmSgmm2Updater::UpdateN(), EbwAmSgmm2Updater::UpdateVars(), and MleAmSgmm2Updater::UpdateVars().
[SSGMM] Speaker-subspace weight projection vectors. Dimension is [I][T]
Definition at line 431 of file am-sgmm2.h.
Referenced by AmSgmm2::CopyFromSgmm2(), AmSgmm2::CopyGlobalsInitVecs(), EbwAmSgmm2Updater::UpdateU(), MleAmSgmm2Updater::UpdateU(), and MleSgmm2SpeakerAccs::UpdateWithU().
The parameters in a particular SGMM state.
v_{jm}, per-state phonetic-subspace vectors. Dimension is [J1][#mix][S].
Definition at line 436 of file am-sgmm2.h.
Referenced by MleAmSgmm2Accs::AccumulateFromPosteriors(), EbwAmSgmm2Updater::ComputePhoneVecStats(), MleAmSgmm2Updater::ComputeQ(), MleAmSgmm2Updater::ComputeSMeans(), AmSgmm2::CopyFromSgmm2(), MleAmSgmm2Updater::RenormalizeV(), EbwAmSgmm2Updater::UpdatePhoneVectorsInternal(), MleAmSgmm2Updater::UpdatePhoneVectorsInternal(), MleAmSgmm2Updater::UpdateW(), and MleAmSgmm2Updater::UpdateWGetStats().
Phonetic-subspace weight projection vectors. Dimension is [I][S].
Definition at line 429 of file am-sgmm2.h.
Referenced by EbwAmSgmm2Updater::ComputePhoneVecStats(), AmSgmm2::CopyFromSgmm2(), AmSgmm2::CopyGlobalsInitVecs(), MleAmSgmm2Updater::RenormalizeV(), EbwAmSgmm2Updater::UpdatePhoneVectorsInternal(), MleAmSgmm2Updater::UpdatePhoneVectorsInternal(), EbwAmSgmm2Updater::UpdateW(), and MleAmSgmm2Updater::UpdateW().
[SSGMM] w_{jmi}, dimension is [J1][#mix][I]. Computed from w_ and v_.
Definition at line 442 of file am-sgmm2.h.
Referenced by MleAmSgmm2Accs::AccumulateFromPosteriors(), MleSgmm2SpeakerAccs::AccumulateFromPosteriors(), AmSgmm2::CopyFromSgmm2(), MleAmSgmm2Updater::Update(), and MleAmSgmm2Updater::UpdateW().