21 #ifndef KALDI_GMM_FULL_GMM_INL_H_ 22 #define KALDI_GMM_FULL_GMM_INL_H_ 43 for (
size_t i = 0;
i < num_comp;
i++) {
57 for (
size_t i = 0;
i < num_comp;
i++) {
60 mean_times_inv.
AddSpVec(1.0, invcovars[i], means.
Row(i), 0.0);
75 for (
size_t i = 0;
i < num_comp;
i++) {
92 for (
size_t i = 0;
i < num_comp;
i++) {
96 orig_mean.
AddSpVec(1.0, covar, orig_mean_times_invvar, 0.0);
97 new_mean_times_invvar.
AddSpVec(1.0, v[i], orig_mean, 0.0);
113 (*v)[
i].InvertDouble();
127 (M->
Row(i)).AddSpVec(1.0, covar, mean_times_invcovar, 0.0);
137 covars->resize(num_gauss);
138 means->
Resize(num_gauss, dim);
140 for (
size_t i = 0;
i < num_gauss;
i++) {
141 (*covars)[
i].Resize(dim);
143 (*covars)[
i].InvertDouble();
145 (means->
Row(i)).AddSpVec(1.0, (*covars)[
i], mean_times_invcovar, 0.0);
161 out->
AddSpVec(1.0, covar, mean_times_invcovar, 0.0);
167 #endif // KALDI_GMM_FULL_GMM_INL_H_ This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void SetWeights(const Vector< Real > &w)
Mutators for both float or double.
Packed symetric matrix class.
int32 Dim() const
Returns the dimensionality of the Gaussian mean vectors.
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
void InvertDouble(Real *logdet=NULL, Real *det_sign=NULL, bool inverse_needed=true)
void SetInvCovarsAndMeans(const std::vector< SpMatrix< Real > > &invcovars, const Matrix< Real > &means)
Use SetInvCovarsAndMeans if updating both means and (inverse) covariances.
Vector< BaseFloat > weights_
weights (not log).
A class for storing matrices.
void AddSpVec(const Real alpha, const SpMatrix< Real > &M, const VectorBase< Real > &v, const Real beta)
Add symmetric positive definite matrix times vector: this <– beta*this + alpha*M*v.
void CopyFromMat(const MatrixBase< OtherReal > &M, MatrixTransposeType trans=kNoTrans)
Copy given matrix. (no resize is done).
void CopyFromSp(const SpMatrix< Real > &other)
void GetCovars(std::vector< SpMatrix< Real > > *v) const
Accessor for covariances.
void CopyFromVec(const VectorBase< Real > &v)
Copy data from another vector (must match own size).
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
bool valid_gconsts_
Recompute gconsts_ if false.
int32 NumGauss() const
Returns the number of mixture components in the GMM.
MatrixIndexT Dim() const
Returns the dimension of the vector.
void SetInvCovarsAndMeansInvCovars(const std::vector< SpMatrix< Real > > &invcovars, const Matrix< Real > &means_invcovars)
Use this if setting both, in the class's native format.
void GetMeans(Matrix< Real > *m) const
Accessor for means.
void SetInvCovars(const std::vector< SpMatrix< Real > > &v)
Set the (inverse) covariances and recompute means_invcovars_.
A class representing a vector.
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty 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).
std::vector< SpMatrix< BaseFloat > > inv_covars_
Inverse covariances.
const Matrix< BaseFloat > & means_invcovars() const
Provides a vector abstraction class.
Matrix< BaseFloat > means_invcovars_
Means times inverse covariances.
void SetZero()
Set vector to all zeros.
void SetMeans(const Matrix< Real > &m)
Use SetMeans to update only the Gaussian means (and not variances)
void GetCovarsAndMeans(std::vector< SpMatrix< Real > > *covars, Matrix< Real > *means) const
Accessor for covariances and means.
void GetComponentMean(int32 gauss, VectorBase< Real > *out) const
Accessor for component mean.