45 gauss_posteriors.
Scale(weight);
55 gauss_posteriors, 1.0);
61 gauss_posteriors, 0.0);
66 this_deriv.
AddVecVec(-1.0, this_feat, temp_vec, 1.0);
85 int32 num_frames = 20;
88 for (
int32 i = 0;
i < num_frames;
i++)
96 bool binary = (
Rand() % 2 == 1);
101 Fmpe fmpe(gmm, opts);
104 Input ki(
"tmpf", &binary_in);
117 feats.
AddMat(1.0, random_offset);
119 feats.
AddMat(-1.0, random_offset);
121 BaseFloat change1 = like_after - like_before,
123 KALDI_LOG <<
"Random offset led to like change " 124 << change1 <<
" (manually), and " << change2
128 KALDI_ASSERT( fabs(change1-change2) < 0.15*fabs(change1+change2));
131 std::vector<std::vector<int32> > gselect(feats.
NumRows());
134 gselect[
i].push_back(
j);
149 fmpe.
AccStats(feats, gselect, deriv, NULL, &stats);
155 feats.
AddMat(1.0, fmpe_offset);
159 BaseFloat delta2 = like_after_update - like_before_update;
160 KALDI_LOG <<
"Change predicted by fMPE Update function is " 161 << delta <<
", change computed directly is " 163 KALDI_ASSERT(fabs(delta-delta2) < 0.15 * fabs(delta+delta2));
173 for (
int i = 0;
i <= 10;
i++)
175 std::cout <<
"Test OK.\n";
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void ComputeFeatures(const MatrixBase< BaseFloat > &feat_in, const std::vector< std::vector< int32 > > &gselect, Matrix< BaseFloat > *feat_out) const
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
const Matrix< BaseFloat > & means_invvars() const
BaseFloat Update(const FmpeUpdateOptions &config, const FmpeStats &stats)
void AddMat(const Real alpha, const MatrixBase< Real > &M, MatrixTransposeType transA=kNoTrans)
*this += alpha * M [or M^T]
float RandGauss(struct RandomState *state=NULL)
void AddVecVec(Real alpha, const VectorBase< Real > &v, const VectorBase< Real > &r, Real beta)
Add element-by-element product of vectors:
bool IsZero(Real cutoff=1.0e-05) const
Returns true if matrix is all zeros.
BaseFloat ComponentPosteriors(const VectorBase< BaseFloat > &data, Vector< BaseFloat > *posteriors) const
Computes the posterior probabilities of all Gaussian components given a data point.
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
void InitRandDiagGmm(int32 dim, int32 num_comp, DiagGmm *gmm)
BaseFloat LogLikelihood(const VectorBase< BaseFloat > &data) const
Returns the log-likelihood of a data point (vector) given the GMM.
BaseFloat GetGmmLike(const DiagGmm &gmm, const Matrix< BaseFloat > &feats)
void Read(std::istream &is, bool binary)
Real TraceMatMat(const MatrixBase< Real > &A, const MatrixBase< Real > &B, MatrixTransposeType trans)
We need to declare this here as it will be a friend function.
void GetFeatDeriv(const DiagGmm &gmm, const Matrix< BaseFloat > &feats, Matrix< BaseFloat > *deriv)
int32 NumGauss() const
Returns the number of mixture components in the GMM.
void Scale(Real alpha)
Multiplies all elements by this constant.
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.
int Rand(struct RandomState *state)
A class representing a vector.
#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).
Definition for Gaussian Mixture Model with diagonal covariances.
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).
Represents a non-allocating general vector which can be defined as a sub-vector of higher-level vecto...
void AccStats(const MatrixBase< BaseFloat > &feat_in, const std::vector< std::vector< int32 > > &gselect, const MatrixBase< BaseFloat > &direct_feat_deriv, const MatrixBase< BaseFloat > *indirect_feat_deriv, FmpeStats *stats) const
const Matrix< BaseFloat > & inv_vars() const
void Write(std::ostream &os, bool binary) const