53 full_dim = inv_lda_mllt.
NumRows();
55 KALDI_ASSERT(start_dim >= 0 && start_dim < end_dim && end_dim <= full_dim);
60 double diag_term = 0.001 / model_dim * B.Trace();
63 for (
int32 i = 0;
i < B.NumRows();
i++)
77 for (
int32 i = model_dim;
i < full_dim;
i++)
83 B_orig.AddMat2Sp(1.0, inv_lda_mllt_dbl,
kNoTrans, B, 0.0);
90 start_dim, end_dim-start_dim)),
91 W_orig_limit(W_orig_mat.
Range(start_dim, end_dim-start_dim,
92 start_dim, end_dim-start_dim));
95 int32 retained_dim = model_dim;
96 if (end_dim - start_dim < retained_dim) retained_dim = end_dim - start_dim;
102 projection->
Resize(retained_dim, full_dim);
108 projection->
Range(0, retained_dim, start_dim, end_dim-start_dim).CopyFromMat(proj);
141 Projection->
Resize(dim_to_retain, dim);
145 KALDI_LOG <<
"Eigenvalues of retained LDA dimensions: " 146 << s.
Range(0, dim_to_retain) <<
" (sum is:) " 147 << s.
Range(0, dim_to_retain).Sum();
148 KALDI_LOG <<
"Eigenvalues of rejected LDA dimensions: " 149 << s.
Range(dim_to_retain, dim - dim_to_retain) <<
" (sum is:) " 150 << s.
Range(dim_to_retain, dim - dim_to_retain).Sum();
155 B_ldaproj.AddMat2Sp(1.0, *Projection,
kNoTrans, B, 0.0);
167 between_covar->
Resize(dim);
168 within_covar->
Resize(dim);
173 between_covar->
AddSp(weight, full_gmm_normal.
vars_[
i]);
177 between_covar->
AddVec2(-1.0, avg_mean);
198 sgmm->
M_[
i].Resize(retained_dim, M.
NumCols());
201 if (!sgmm->
N_.empty()) {
204 sgmm->
N_[
i].Resize(retained_dim, N.
NumCols());
219 small_projection_dbl,
kTrans, 0.0);
246 extended_var(
i,
i) = 1.0;
249 if (tgt_dim < variance->NumRows()) variance->
Resize(tgt_dim);
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
bool IsUnit(Real cutoff=1.0e-05) const
Class for definition of the subspace Gmm acoustic model.
int32 Dim() const
Returns the dimensionality of the Gaussian mean vectors.
Definition for Gaussian Mixture Model with full covariances in normal mode: where the parameters are ...
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
int32 ComputeGconsts()
Sets the gconsts.
Definition for Gaussian Mixture Model with full covariances.
void Resize(int32 nMix, int32 dim)
Resizes arrays to this dim. Does not initialize data.
void ComputeProjection(const AmSgmm2 &sgmm, const Matrix< BaseFloat > &inv_lda_mllt, int32 begin_dim, int32 end_dim, Matrix< BaseFloat > *projection)
int32 ComputeGconsts()
Sets the gconsts.
DiagGmm diag_ubm_
These contain the "background" model associated with the subspace GMM.
std::vector< Matrix< BaseFloat > > n_
n_{jim}, per-Gaussian normalizer. Dimension is [J1][I][#mix]
std::vector< Matrix< BaseFloat > > N_
Speaker-subspace projections. Dimension is [I][D][T].
void ApplyProjection(const Matrix< BaseFloat > &total_projection, AmSgmm2 *sgmm)
MatrixIndexT NumRows() const
const FullGmm & full_ubm() const
Accessors.
void CopyFromSp(const SpMatrix< Real > &other)
std::vector< SpMatrix< double > > vars_
covariances
void AddTp2Sp(const Real alpha, const TpMatrix< Real > &T, MatrixTransposeType transM, const SpMatrix< Real > &A, const Real beta=0.0)
The following function does: this <– beta*this + alpha * T * A * T^T.
std::vector< Matrix< BaseFloat > > M_
Phonetic-subspace projections. Dimension is [I][D][S].
void AddVec2(const Real alpha, const VectorBase< OtherReal > &v)
rank-one update, this <– this + alpha v v'
void Cholesky(const SpMatrix< Real > &orig)
void Resize(int32 nMix, int32 dim)
Resizes arrays to this dim. Does not initialize data.
void ComputeLdaStats(const FullGmm &full_ubm, SpMatrix< double > *between_covar, SpMatrix< double > *within_covar)
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
std::vector< SpMatrix< BaseFloat > > SigmaInv_
Globally shared parameters of the subspace GMM.
void ProjectVariance(const Matrix< double > &total_projection, bool inverse, SpMatrix< double > *variance)
void AddSp(const Real alpha, const SpMatrix< Real > &Ma)
void AddMatMat(const Real alpha, const MatrixBase< Real > &A, MatrixTransposeType transA, const MatrixBase< Real > &B, MatrixTransposeType transB, const Real beta)
void CopyToFullGmm(FullGmm *fullgmm, GmmFlagsType flags=kGmmAll)
Copies to FullGmm.
int32 NumGauss() const
Returns the number of mixture components in the GMM.
void ComputeLdaTransform(const SpMatrix< double > &B, const SpMatrix< double > &W, int32 dim_to_retain, Matrix< double > *Projection)
void CopyFromFullGmm(const FullGmm &fullgmm)
Copies from given FullGmm.
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void AddMat2Sp(const Real alpha, const MatrixBase< Real > &M, MatrixTransposeType transM, const SpMatrix< Real > &A, const Real beta=0.0)
Extension of rank-N update: this <– beta*this + alpha * M * A * M^T.
SubMatrix< Real > Range(const MatrixIndexT row_offset, const MatrixIndexT num_rows, const MatrixIndexT col_offset, const MatrixIndexT num_cols) const
Return a sub-part of matrix.
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 Resize(MatrixIndexT nRows, MatrixResizeType resize_type=kSetZero)
void SymPosSemiDefEig(VectorBase< Real > *s, MatrixBase< Real > *P, Real tolerance=0.001) const
This is the version of SVD that we implement for symmetric positive definite matrices.
void AddMatTp(const Real alpha, const MatrixBase< Real > &A, MatrixTransposeType transA, const TpMatrix< Real > &B, MatrixTransposeType transB, const Real beta)
this <– beta*this + alpha*A*B.
Matrix< double > means_
Means.
void Invert(Real *logdet=NULL, Real *det_sign=NULL, bool inverse_needed=true)
matrix inverse.
void AddVec(const Real alpha, const VectorBase< OtherReal > &v)
Add vector : *this = *this + alpha * rv (with casting between floats and doubles) ...
Sub-matrix representation.
SubVector< Real > Range(const MatrixIndexT o, const MatrixIndexT l)
Returns a sub-vector of a vector (a range of elements).