32   : dim_(other.dim_), num_comp_(other.num_comp_),
    33     flags_(other.flags_), occupancy_(other.occupancy_),
    34     mean_accumulator_(other.mean_accumulator_),
    35     covariance_accumulator_(other.covariance_accumulator_) {}
    57   for (
int32 i = 0; 
i < num_comp; 
i++) {
    65     KALDI_ERR << 
"Flags in argument do not match the active accumulators";
    81     KALDI_ERR << 
"Flags in argument do not match the active accumulators";
    83   double d = 
static_cast<double>(f);
    99   double wt = 
static_cast<double>(weight);
   124     if (static_cast<int32>(post_d.Norm(0.0)*2.0) > post_d.Dim()) {
   129       for (
int32 i = 0; 
i < post_d.Dim(); 
i++)
   130         if (post_d(
i) != 0.0)
   135       data_sq_d.
AddVec2(1.0, data_d);
   137         if (post_d(mix) !=  0.0)
   151   component_posterior.Scale(frame_posterior);
   165   component_posterior.Scale(frame_posterior);
   172   int32 dimension, num_components;
   187       if (num_components != 
NumGauss() || dimension != 
Dim()
   189         KALDI_ERR << 
"MlEstimatediagGmm::Read, dimension or flags mismatch, "   192                   << dimension << 
", " << flags;
   194       Resize(num_components, dimension, flags);
   197     Resize(num_components, dimension, flags);
   205   while (token != 
"</GMMACCS>") {
   206     if (token == 
"<OCCUPANCY>") {
   207       tmp_occs.
Read(in_stream, binary, 
false);
   210     } 
else if (token == 
"<MEANACCS>") {
   211       tmp_means.
Read(in_stream, binary, 
false);
   214     } 
else if (token == 
"<FULLVARACCS>") {
   215       for (
int32 i = 0; 
i < num_components; 
i++) {
   217         tmp_acc.
Read(in_stream, binary, add);
   218         if (tmp_occs(
i) != 0) tmp_acc.
AddVec2(1.0 / tmp_occs(
i), tmp_means.
Row(
   224       KALDI_ERR << 
"Unexpected token '" << token << 
"' in model file ";
   234   WriteToken(out_stream, binary, 
"<NUMCOMPONENTS>");
   240   WriteToken(out_stream, binary, 
"<OCCUPANCY>");
   241   occupancy_bf.
Write(out_stream, binary);
   244   mean_accumulator_bf.
Write(out_stream, binary);
   249     WriteToken(out_stream, binary, 
"<FULLVARACCS>");
   255       tmp_acc_bf.
Write(out_stream, binary);
   290   if (flags & ~fullgmm_acc.
Flags())
   291     KALDI_ERR << 
"Flags in argument do not match the active accumulators";
   305   int32 tot_floored = 0, gauss_floored = 0;
   310   std::vector<int32> to_remove;
   311   for (
int32 i = 0; 
i < num_gauss; 
i++) {
   315       prob = occ / occ_sum;
   317       prob = 1.0 / num_gauss;
   330         mean.
Scale(1.0 / occ);
   339         covar.
Scale(1.0 / occ);
   345           covar.AddVec2(1.0, oldmean);
   352         int32 floored = covar.ApplyFloor(floor);
   355           tot_floored += floored;
   360         ngmm.
vars_[
i].CopyFromSp(covar);
   364             static_cast<int32>(to_remove.size()) < num_gauss-1) {
   365         KALDI_WARN << 
"Too little data - removing Gaussian (weight "   366                    << std::fixed << prob
   367                    << 
", occupation count " << std::fixed << fullgmm_acc.
occupancy()(
i)
   368                    << 
", vector size " << gmm->
Dim() << 
")";
   369         to_remove.push_back(
i);
   371         KALDI_WARN << 
"Gaussian has too little data but not removing it because"   373                        " it is the last Gaussian: i = "   374                        : 
" remove-low-count-gaussians == false: i = ") << 
i   375                    << 
", occ = " << fullgmm_acc.
occupancy()(
i) << 
", weight = " << prob;
   389     *obj_change_out = obj_new - obj_old;
   392     *count_out = occ_sum;
   394   if (to_remove.size() > 0) {
   400     KALDI_WARN << tot_floored << 
" variances floored in " << gauss_floored
 void Write(std::ostream &out_stream, bool binary) const
 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
int32 Dim() const
Returns the dimensionality of the Gaussian mean vectors. 
 
GmmFlagsType AugmentGmmFlags(GmmFlagsType f)
Returns "augmented" version of flags: e.g. 
 
void Write(std::ostream &out, bool binary) const
write to stream. 
 
const std::vector< SpMatrix< BaseFloat > > & inv_covars() const
 
int32 NumGauss() const
Returns the number of mixture components. 
 
const std::vector< SpMatrix< double > > & covariance_accumulator() const
 
void Read(std::istream &in, bool binary, bool add=false)
 
void Write(std::ostream &out, bool binary) const
 
std::vector< SpMatrix< double > > covariance_accumulator_
 
BaseFloat ComponentPosteriors(const VectorBase< BaseFloat > &data, VectorBase< BaseFloat > *posterior) const
Computes the posterior probabilities of all Gaussian components given a data point. 
 
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 ...
 
Configuration variables like variance floor, minimum occupancy, etc. 
 
void ReadBasicType(std::istream &is, bool binary, T *t)
ReadBasicType is the name of the read function for bool, integer types, and floating-point types...
 
void ResizeVarAccumulator(int32 num_comp, int32 dim)
 
BaseFloat AccumulateFromDiag(const DiagGmm &gmm, const VectorBase< BaseFloat > &data, BaseFloat frame_posterior)
Accumulate for all components given a diagonal-covariance GMM. 
 
int32 ComputeGconsts()
Sets the gconsts. 
 
Definition for Gaussian Mixture Model with full covariances. 
 
void Write(std::ostream &Out, bool binary) const
Writes to C++ stream (option to write in binary). 
 
BaseFloat MlObjective(const DiagGmm &gmm, const AccumDiagGmm &diag_gmm_acc)
Calc using the DiagGMM exponential form. 
 
void AddMat(const Real alpha, const MatrixBase< Real > &M, MatrixTransposeType transA=kNoTrans)
*this += alpha * M [or M^T] 
 
Vector< double > occupancy_
 
int32 Dim() const
Returns the dimensionality of the feature vectors. 
 
void ReadToken(std::istream &is, bool binary, std::string *str)
ReadToken gets the next token and puts it in str (exception on failure). 
 
uint16 GmmFlagsType
Bitwise OR of the above flags. 
 
void SetZero(GmmFlagsType flags)
 
void Resize(MatrixIndexT length, MatrixResizeType resize_type=kSetZero)
Set vector to a specified size (can be zero). 
 
GmmFlagsType Flags() const
Accessors. 
 
const Vector< double > & occupancy() const
 
BaseFloat variance_floor
Floor on eigenvalues of covariance matrices. 
 
const Vector< BaseFloat > & gconsts() const
Const accessors. 
 
std::vector< SpMatrix< double > > vars_
covariances 
 
void Resize(int32 num_components, int32 dim, GmmFlagsType flags)
Allocates memory for accumulators. 
 
void CopyFromVec(const VectorBase< Real > &v)
Copy data from another vector (must match own size). 
 
void AddVec2(const Real alpha, const VectorBase< OtherReal > &v)
rank-one update, this <– this + alpha v v' 
 
void Read(std::istream &in, bool binary, bool add=false)
read from stream. 
 
BaseFloat ComponentPosteriors(const VectorBase< BaseFloat > &data, Vector< BaseFloat > *posteriors) const
Computes the posterior probabilities of all Gaussian components given a data point. 
 
Vector< double > weights_
weights (not log). 
 
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const]. 
 
void AccumulateFromPosteriors(const VectorBase< BaseFloat > &data, const VectorBase< BaseFloat > &gauss_posteriors)
Accumulate for all components, given the posteriors. 
 
BaseFloat min_gaussian_weight
Minimum weight below which a Gaussian is removed. 
 
void RemoveComponents(const std::vector< int32 > &gauss, bool renorm_weights)
Removes multiple components from model; "gauss" must not have dups. 
 
void Scale(Real alpha)
Multiply each element with a scalar value. 
 
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
 
bool remove_low_count_gaussians
 
void MleFullGmmUpdate(const MleFullGmmOptions &config, const AccumFullGmm &fullgmm_acc, GmmFlagsType flags, FullGmm *gmm, BaseFloat *obj_change_out, BaseFloat *count_out)
for computing the maximum-likelihood estimates of the parameters of a Gaussian mixture model...
 
double TraceSpSp(const SpMatrix< double > &A, const SpMatrix< double > &B)
 
Class for computing the maximum-likelihood estimates of the parameters of a Gaussian mixture model...
 
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 CopyToFullGmm(FullGmm *fullgmm, GmmFlagsType flags=kGmmAll)
Copies to FullGmm. 
 
int32 NumGauss() const
Returns the number of mixture components in the GMM. 
 
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters. 
 
int32 NumGauss() const
Returns the number of mixture components in the GMM. 
 
MatrixIndexT Dim() const
Returns the dimension of the vector. 
 
void SetZero()
Sets matrix to zero. 
 
void Scale(Real alpha)
Multiplies all elements by this constant. 
 
const Matrix< double > & mean_accumulator() const
 
Real Sum() const
Returns sum of the elements. 
 
BaseFloat min_gaussian_occupancy
Minimum occupancy count below which a Gaussian is removed. 
 
void Read(std::istream &in_stream, bool binary, bool add)
 
#define KALDI_ASSERT(cond)
 
void AddVecVec(const Real alpha, const VectorBase< OtherReal > &a, const VectorBase< OtherReal > &b)
*this += alpha * a * b^T 
 
void CopyRowFromVec(const VectorBase< Real > &v, const MatrixIndexT row)
Copy vector into specific row of matrix. 
 
Definition for Gaussian Mixture Model with diagonal covariances. 
 
std::string GmmFlagsToString(GmmFlagsType flags)
Convert GMM flags to string. 
 
void WriteBasicType(std::ostream &os, bool binary, T t)
WriteBasicType is the name of the write function for bool, integer types, and floating-point types...
 
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). 
 
BaseFloat AccumulateFromFull(const FullGmm &gmm, const VectorBase< BaseFloat > &data, BaseFloat frame_posterior)
Accumulate for all components given a full-covariance GMM. 
 
BaseFloat max_condition
Maximum condition number of covariance matrices (apply floor to eigenvalues if they pass this)...
 
const Matrix< BaseFloat > & means_invcovars() const
 
Provides a vector abstraction class. 
 
void SetZero()
Set vector to all zeros. 
 
Matrix< double > means_
Means. 
 
Real VecVec(const VectorBase< Real > &a, const VectorBase< Real > &b)
Returns dot product between v1 and v2. 
 
void AddVec(const Real alpha, const VectorBase< OtherReal > &v)
Add vector : *this = *this + alpha * rv (with casting between floats and doubles) ...
 
Matrix< double > mean_accumulator_
 
void Read(std::istream &in, bool binary, bool add=false)
Read function using C++ streams. 
 
void Scale(BaseFloat f, GmmFlagsType flags)
 
void AccumulateForComponent(const VectorBase< BaseFloat > &data, int32 comp_index, BaseFloat weight)
Accumulate for a single component, given the posterior.