40 using namespace kaldi;
53 std::vector<int32> gselect;
56 loglike += accs.Accumulate(sgmm, frame_vars, 0, 1.0, &empty);
58 accs.CommitStatsForSpk(sgmm, empty);
64 updater.
Update(accs, sgmm1, flags);
66 std::vector<int32> gselect;
81 accs1->
Check(sgmm,
true);
84 updater.
Update(*accs1, sgmm2, flags);
99 accs2->
Check(sgmm,
true);
102 updater.
Update(*accs2, sgmm3, flags);
116 updater_map.
Update(*accs2, sgmm3, flags);
134 std::vector<int32> pdf2group;
135 pdf2group.push_back(0);
144 vars(num_feat_comp, dim);
145 for (
int32 m = 0; m < num_feat_comp; m++) {
152 feats.
Resize(num_feat_comp * 200, dim);
153 for (
int32 m = 0; m < num_feat_comp; m++) {
163 for (
int i = 0;
i < 10;
i++)
165 std::cout <<
"Test OK.\n";
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void Write(std::ostream &os, bool binary, SgmmWriteFlagsType write_params) const
Class for definition of the subspace Gmm acoustic model.
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.
void UnitTestEstimateSgmm2()
Definition for Gaussian Mixture Model with full covariances.
void Read(std::istream &in_stream, bool binary, bool add)
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 TestSgmm2AccsIO(const AmSgmm2 &sgmm, const kaldi::Matrix< BaseFloat > &feats)
int32 PhoneSpaceDim() const
bool full_row_cov
Estimate row covariance instead of using I.
void Update(const MleAmSgmm2Accs &accs, AmSgmm2 *model, SgmmUpdateFlagsType flags)
t .. not really part of SGMM.
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...
uint16 SgmmUpdateFlagsType
Bitwise OR of the above flags.
bool full_col_cov
Estimate col covariance instead of using I.
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
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).
int32 NumPdfs() const
Various model dimensions.
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 Write(std::ostream &out_stream, bool binary) const
void InitRandFullGmm(int32 dim, int32 num_comp, FullGmm *gmm)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void ComputeDerivedVars()
Computes (and initializes if necessary) derived vars...
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.
BaseFloat tau_map_M
For MAP update of the phonetic subspace M.
void RandDiagGaussFeatures(int32 num_samples, const VectorBase< BaseFloat > &mean, const VectorBase< BaseFloat > &sqrt_var, MatrixBase< BaseFloat > *feats)
void Resize(const MatrixIndexT r, const MatrixIndexT c, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride)
Sets matrix to a specified size (zero is OK as long as both r and c are zero).
void Check(const AmSgmm2 &model, bool show_properties=true) const
Checks the various accumulators for correct sizes given a model.
Configuration variables needed in the SGMM estimation process.
Class for the accumulators associated with the phonetic-subspace model parameters.
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)