44 tmp.Range(0, dim).CopyFromVec(in);
55 using namespace kaldi;
82 std::vector<int32> gselect;
98 accs.
Update(sgmm, fmllr_globals, update_opts, &xform_mat, &frames, &impr);
107 &like_cache, &empty);
118 accs1->
Update(sgmm, fmllr_globals, update_opts, &xform_mat, NULL, NULL);
122 like_cache.NextFrame();
124 &like_cache, &empty);
125 std::cout <<
"LL1 = " << loglike1 <<
", LL2 = " << loglike2 << std::endl;
138 accs2->
Update(sgmm, fmllr_globals, update_opts, &xform_mat, NULL, NULL);
143 &like_cache, &empty);
144 std::cout <<
"LL1 = " << loglike1 <<
", LL3 = " << loglike3 << std::endl;
156 using namespace kaldi;
180 std::vector<int32> gselect;
184 loglike += accs.
Accumulate(sgmm, feats.
Row(
i), frame_vars, 0, 1.0,
196 accs.
Update(sgmm, fmllr_globals, update_opts, &xform_mat, NULL, NULL);
209 std::vector<int32> pdf2group;
210 pdf2group.push_back(0);
219 vars(num_feat_comp, dim);
220 for (
int32 m = 0; m < num_feat_comp; m++) {
227 feats.
Resize(num_feat_comp * 200, dim);
228 for (
int32 m = 0; m < num_feat_comp; m++) {
239 for (
int i = 0;
i < 10;
i++)
241 std::cout <<
"Test OK.\n";
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Class for definition of the subspace Gmm acoustic model.
void TestSgmm2FmllrAccsIO(const AmSgmm2 &sgmm, const kaldi::Matrix< BaseFloat > &feats)
Class for computing the accumulators needed for the maximum-likelihood estimate of FMLLR transforms f...
Matrix< BaseFloat > pre_xform_
Pre-transform matrix. Dim is [D][D+1].
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
Definition for Gaussian Mixture Model with full covariances.
void ApplyFmllrXform(const kaldi::VectorBase< BaseFloat > &in, const Matrix< BaseFloat > &xf, Vector< BaseFloat > *out)
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)
A class for storing matrices.
void Resize(MatrixIndexT length, MatrixResizeType resize_type=kSetZero)
Set vector to a specified size (can be zero).
void TestSgmm2FmllrSubspace(const AmSgmm2 &sgmm, const kaldi::Matrix< BaseFloat > &feats)
int32 PhoneSpaceDim() const
void SetUnit()
Sets to zero, except ones along diagonal [for non-square matrices too].
void EstimateSgmm2FmllrSubspace(const SpMatrix< double > &fmllr_grad_scatter, int32 num_fmllr_bases, int32 feat_dim, Sgmm2FmllrGlobalParams *globals, double min_eig)
Computes the fMLLR basis matrices given the scatter of the vectorized gradients (eq: B...
void AccumulateForFmllrSubspace(const AmSgmm2 &sgmm, const Sgmm2FmllrGlobalParams &fmllr_globals, SpMatrix< double > *grad_scatter)
bool Update(const AmSgmm2 &model, const Sgmm2FmllrGlobalParams &fmllr_globals, const Sgmm2FmllrConfig &opts, Matrix< BaseFloat > *out_xform, BaseFloat *frame_count, BaseFloat *auxf_improv) const
Computes the FMLLR transform from the accumulated stats, using the pre-transforms in fmllr_globals...
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 Read(std::istream &in_stream, bool binary, bool add)
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
Matrix< BaseFloat > inv_xform_
Inverse of pre-transform. Dim is [D][D+1].
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)
MatrixIndexT Dim() const
Returns the dimension of the vector.
void AddMatVec(const Real alpha, const MatrixBase< Real > &M, const MatrixTransposeType trans, const VectorBase< Real > &v, const Real beta)
Add matrix times vector : this <– beta*this + alpha*M*v.
Configuration variables needed in the estimation of FMLLR for SGMMs.
int32 num_fmllr_bases
Number of basis matrices to use for FMLLR estimation.
void InitRandFullGmm(int32 dim, int32 num_comp, FullGmm *gmm)
A class representing a vector.
BaseFloat Accumulate(const AmSgmm2 &sgmm, const VectorBase< BaseFloat > &data, const Sgmm2PerFrameDerivedVars &frame_vars, int32 state_index, BaseFloat weight, Sgmm2PerSpkDerivedVars *spk)
Accumulation routine that computes the Gaussian posteriors and calls the AccumulateFromPosteriors fun...
#define KALDI_ASSERT(cond)
int32 g_kaldi_verbose_level
This is set by util/parse-options.
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void Write(std::ostream &out_stream, bool binary) const
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.
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).
Global adaptation parameters.
Provides a vector abstraction class.
Vector< BaseFloat > mean_scatter_
Diagonal of mean-scatter matrix. Dim is [D].
void Init(int32 dim, int32 num_gaussians)
Holds the per-frame precomputed quantities x(t), x_{i}(t), z_{i}(t), and n_{i}(t) (cf...
BaseFloat fmllr_min_count
Minimum occupancy count to estimate FMLLR without basis matrices.
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 ...