91 BaseFloat log_like = gmm.ComponentPosteriors(data1, &posteriors);
92 posteriors.
Scale(weight);
129 (*it)->Read(in_stream, binary, add);
133 KALDI_ERR <<
"Adding accumulators but num-pdfs do not match: " 138 (*it)->Read(in_stream, binary, add);
142 if (!in_stream.eof()) {
157 for (std::vector<AccumDiagGmm*>::const_iterator it =
159 (*it)->Write(out_stream, binary);
161 WriteToken(out_stream, binary,
"<total_like>");
164 WriteToken(out_stream, binary,
"<total_frames>");
177 for (
int32 pdf_id = 0; pdf_id < am_gmm->
NumPdfs(); pdf_id++) {
193 if (am_diag_gmm_acc.
Dim() != am_gmm->
Dim()) {
195 KALDI_WARN <<
"Dimensions of accumulator " << am_diag_gmm_acc.
Dim()
196 <<
" and gmm " << am_gmm->
Dim() <<
" do not match, resizing " 197 <<
" GMM and setting to zero-mean, unit-variance.";
203 if (obj_change_out != NULL) *obj_change_out = 0.0;
204 if (count_out != NULL) *count_out = 0.0;
206 BaseFloat tot_obj_change = 0.0, tot_count = 0.0;
207 int32 tot_elems_floored = 0, tot_gauss_floored = 0,
208 tot_gauss_removed = 0;
211 int32 elems_floored, gauss_floored, gauss_removed;
215 &obj_change, &count, &elems_floored,
216 &gauss_floored, &gauss_removed);
217 tot_obj_change += obj_change;
219 tot_elems_floored += elems_floored;
220 tot_gauss_floored += gauss_floored;
221 tot_gauss_removed += gauss_removed;
223 if (obj_change_out != NULL) *obj_change_out = tot_obj_change;
224 if (count_out != NULL) *count_out = tot_count;
225 KALDI_LOG << tot_elems_floored <<
" variance elements floored in " 226 << tot_gauss_floored <<
" Gaussians, out of " 229 KALDI_LOG <<
"Removed " << tot_gauss_removed
230 <<
" Gaussians due to counts < --min-gaussian-occupancy=" 232 <<
" and --remove-low-count-gaussians=true";
245 if (obj_change_out != NULL) *obj_change_out = 0.0;
246 if (count_out != NULL) *count_out = 0.0;
248 BaseFloat *p_obj = (obj_change_out != NULL) ? &tmp_obj_change : NULL,
249 *p_count = (count_out != NULL) ? &tmp_count : NULL;
253 &(am_gmm->
GetPdf(
i)), p_obj, p_count);
255 if (obj_change_out != NULL) *obj_change_out += tmp_obj_change;
256 if (count_out != NULL) *count_out += tmp_count;
285 for (
int32 i = 0;
i < num_accs;
i++)
void MleAmDiagGmmUpdate(const MleDiagGmmOptions &config, const AccumAmDiagGmm &am_diag_gmm_acc, GmmFlagsType flags, AmDiagGmm *am_gmm, BaseFloat *obj_change_out, BaseFloat *count_out)
for computing the maximum-likelihood estimates of the parameters of an acoustic model that uses diago...
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void MapDiagGmmUpdate(const MapDiagGmmOptions &config, const AccumDiagGmm &diag_gmm_acc, GmmFlagsType flags, DiagGmm *gmm, BaseFloat *obj_change_out, BaseFloat *count_out)
Maximum A Posteriori estimation of the model.
bool remove_low_count_gaussians
void DeletePointers(std::vector< A *> *v)
Deletes any non-NULL pointers in the vector v, and sets the corresponding entries of v to NULL...
void MapAmDiagGmmUpdate(const MapDiagGmmOptions &config, const AccumAmDiagGmm &am_diag_gmm_acc, GmmFlagsType flags, AmDiagGmm *am_gmm, BaseFloat *obj_change_out, BaseFloat *count_out)
Maximum A Posteriori update.
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...
BaseFloat min_gaussian_occupancy
Minimum count below which a Gaussian is not updated (and is removed, if remove_low_count_gaussians ==...
void MleDiagGmmUpdate(const MleDiagGmmOptions &config, const AccumDiagGmm &diag_gmm_acc, GmmFlagsType flags, DiagGmm *gmm, BaseFloat *obj_change_out, BaseFloat *count_out, int32 *floored_elements_out, int32 *floored_gaussians_out, int32 *removed_gaussians_out)
for computing the maximum-likelihood estimates of the parameters of a Gaussian mixture model...
void SetZero(GmmFlagsType flags)
BaseFloat AccumulateForGmmTwofeats(const AmDiagGmm &model, const VectorBase< BaseFloat > &data1, const VectorBase< BaseFloat > &data2, int32 gmm_index, BaseFloat weight)
Accumulate stats for a single GMM in the model; uses data1 for getting posteriors and data2 for stats...
BaseFloat AccumulateForGmm(const AmDiagGmm &model, const VectorBase< BaseFloat > &data, int32 gmm_index, BaseFloat weight)
Accumulate stats for a single GMM in the model; returns log likelihood.
void Resize(int32 nMix, int32 dim)
Resizes arrays to this dim. Does not initialize data.
int32 ComputeGconsts()
Sets the gconsts.
const VectorBase< double > & occupancy() const
uint16 GmmFlagsType
Bitwise OR of the above flags.
void Scale(BaseFloat f, GmmFlagsType flags)
void Add(BaseFloat scale, const AccumAmDiagGmm &other)
void ResizeModel(int32 dim, AmDiagGmm *am_gmm)
void AccumulateFromPosteriors(const AmDiagGmm &model, const VectorBase< BaseFloat > &data, int32 gmm_index, const VectorBase< BaseFloat > &posteriors)
Accumulates stats for a single GMM in the model using pre-computed Gaussian posteriors.
double total_frames_
Total counts & likelihood (for diagnostics)
void AccumulateForGaussian(const AmDiagGmm &am, const VectorBase< BaseFloat > &data, int32 gmm_index, int32 gauss_index, BaseFloat weight)
Accumulate stats for a single Gaussian component in the model.
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
GmmFlagsType Flags() const
void Scale(BaseFloat scale)
BaseFloat TotStatsCount() const
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.
Configuration variables like variance floor, minimum occupancy, etc.
void Scale(Real alpha)
Multiplies all elements by this constant.
Real Sum() const
Returns sum of the elements.
void Read(std::istream &in_stream, bool binary, bool add=false)
void SetInvVars(const MatrixBase< Real > &v)
Set the (inverse) variances and recompute means_invvars_.
DiagGmm & GetPdf(int32 pdf_index)
Accessors.
A class representing a vector.
const AccumDiagGmm & GetAcc(int32 index) const
#define KALDI_ASSERT(cond)
void Write(std::ostream &out_stream, bool binary) const
Definition for Gaussian Mixture Model with diagonal covariances.
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...
Provides a vector abstraction class.
void AccumulateFromPosteriors(const VectorBase< BaseFloat > &data, const VectorBase< BaseFloat > &gauss_posteriors)
Accumulate for all components, given the posteriors.
void Init(const AmDiagGmm &model, GmmFlagsType flags)
Initializes accumulators for each GMM based on the number of components and dimension.
std::vector< AccumDiagGmm * > gmm_accumulators_
MLE accumulators and update methods for the GMMs.
void Set(Real)
Sets all elements to a specific value.
Configuration variables for Maximum A Posteriori (MAP) update.