34 using namespace kaldi;
47 std::vector<int32> gselect;
54 sgmm_cache.NextFrame();
61 sgmm_cache.NextFrame();
72 sgmm_cache.NextFrame();
80 std::vector<int32> pdf2group(sgmm.
NumPdfs());
88 sgmm_cache.NextFrame();
97 using namespace kaldi;
110 std::vector<int32> gselect;
153 using namespace kaldi;
156 for (
int32 i = 0;
i < occs.Dim();
i++)
174 std::vector<int32> gselect;
185 sgmm_cache.NextFrame();
193 using namespace kaldi;
206 std::vector<int32> gselect;
217 sgmm1->CopyFromSgmm2(sgmm,
false,
false);
219 sgmm1->IncreasePhoneSpaceDim(target_phn_dim, norm_xform);
220 sgmm1->ComputeNormalizers();
224 sgmm1->GaussianSelection(config, feat, &gselect);
225 sgmm1->ComputePerFrameVars(feat, gselect, empty, &per_frame);
226 sgmm_cache.NextFrame();
227 BaseFloat loglike1 = sgmm1->LogLikelihood(per_frame, 0, &sgmm_cache, &empty);
230 sgmm1->IncreaseSpkSpaceDim(target_spk_dim, norm_xform,
true);
232 sgmm1->GaussianSelection(config, feat, &gselect);
233 sgmm1->ComputePerFrameVars(feat, gselect, empty, &per_frame);
234 sgmm_cache.NextFrame();
235 BaseFloat loglike2 = sgmm1->LogLikelihood(per_frame, 0, &sgmm_cache, &empty);
248 a_inv(inv_xform, 0, dim, 0, dim);
250 b_pre.CopyColFromMat(xform, dim);
257 res_vec.AddVec(1.0, b_inv);
267 std::vector<int32> pdf2group;
268 pdf2group.push_back(0);
281 for (
int i = 0;
i < 10;
i++)
283 std::cout <<
"Test OK.\n";
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void ComputeWeights()
Computes the weights w_jmi_, which is needed for likelihood evaluation with SSGMMs.
void Write(std::ostream &os, bool binary, SgmmWriteFlagsType write_params) const
Class for definition of the subspace Gmm acoustic model.
void TestSgmm2PreXform(const AmSgmm2 &sgmm)
void CopyFromSgmm2(const AmSgmm2 &other, bool copy_normalizers, bool copy_weights)
Used to copy models (useful in update)
float RandUniform(struct RandomState *state=NULL)
Returns a random number strictly between 0 and 1.
Definition for Gaussian Mixture Model with full covariances.
void Read(std::istream &is, bool binary)
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.
float RandGauss(struct RandomState *state=NULL)
void TestSgmm2IncreaseDim(const AmSgmm2 &sgmm)
const FullGmm & full_ubm() const
Accessors.
int32 PhoneSpaceDim() const
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 p...
void SplitSubstates(const Vector< BaseFloat > &state_occupancies, const Sgmm2SplitSubstatesConfig &config)
Increases the total number of substates based on the state occupancies.
int32 Pdf2Group(int32 j2) const
void Check(bool show_properties=true)
Checks the various components for correct sizes.
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).
void TestSgmm2IO(const AmSgmm2 &sgmm)
void TestSgmm2Substates(const AmSgmm2 &sgmm)
int32 NumPdfs() const
Various model dimensions.
void AddMatMat(const Real alpha, const MatrixBase< Real > &A, MatrixTransposeType transA, const MatrixBase< Real > &B, MatrixTransposeType transB, const Real beta)
int32 full_gmm_nbest
Number of highest-scoring full-covariance Gaussians per frame.
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: ...
void Resize(int32 ngauss, int32 feat_dim, int32 phn_dim)
void TestSgmm2Init(const AmSgmm2 &sgmm)
void InitRandFullGmm(int32 dim, int32 num_comp, FullGmm *gmm)
void CopyColFromMat(const MatrixBase< OtherReal > &M, MatrixIndexT col)
Extracts a column of the matrix M.
A class representing a vector.
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void Set(Real f)
Set all members of a vector to a specified value.
void ComputeNormalizers()
Computes the data-independent terms in the log-likelihood computation for each Gaussian component and...
static void AssertEqual(float a, float b, float relative_tolerance=0.001)
assert abs(a - b) <= relative_tolerance * (abs(a)+abs(b))
Sgmm2LikelihoodCache caches SGMM likelihoods at two levels: the final pdf likelihoods, and the sub-state level likelihoods, which means that with the SCTM system we can avoid redundant computation.
bool IsUnit(Real cutoff=1.0e-05) const
Returns true if the matrix is all zeros, except for ones on diagonal.
int32 SpkSpaceDim() const
void ComputeFeatureNormalizingTransform(const FullGmm &gmm, Matrix< BaseFloat > *xform)
Computes the inverse of an LDA transform (without dimensionality reduction) The computed transform is...
Holds the per-frame precomputed quantities x(t), x_{i}(t), z_{i}(t), and n_{i}(t) (cf...
Sub-matrix representation.
int32 RandInt(int32 min_val, int32 max_val, struct RandomState *state)
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 ...