27 using namespace kaldi;
31 "Do \"re-scaling\" re-estimation of GMM-based model\n" 32 " (this update changes the model as features change, but preserves\n" 33 " the difference between the model and the features, to keep\n" 34 " the effect of any prior discriminative training). Used in fMPE.\n" 35 " Does not update the transitions or weights.\n" 36 "Usage: gmm-est-rescale [options] <model-in> <old-stats-in> <new-stats-in> <model-out>\n" 37 "e.g.: gmm-est-rescale 1.mdl old.acc new.acc 2.mdl\n";
39 bool binary_write =
true;
46 po.Register(
"binary", &binary_write,
"Write output in binary mode");
47 po.Register(
"min-variance", &min_variance,
48 "Variance floor (absolute variance).");
49 po.Register(
"min-gaussian-occupancy", &min_gaussian_occupancy,
50 "Minimum occupancy to update a Gaussian.");
54 if (po.NumArgs() != 4) {
59 std::string model_rxfilename = po.GetArg(1),
60 old_stats_rxfilename = po.GetArg(2),
61 new_stats_rxfilename = po.GetArg(3),
62 model_wxfilename = po.GetArg(4);
68 Input ki(model_rxfilename, &binary_read);
69 trans_model.
Read(ki.Stream(), binary_read);
70 am_gmm.
Read(ki.Stream(), binary_read);
77 Input ki(old_stats_rxfilename, &binary);
78 transition_accs.
Read(ki.Stream(), binary);
79 old_gmm_accs.
Read(ki.Stream(), binary,
true);
84 Input ki(new_stats_rxfilename, &binary);
85 transition_accs.
Read(ki.Stream(), binary);
86 new_gmm_accs.
Read(ki.Stream(), binary,
true);
90 min_variance, min_gaussian_occupancy,
94 Output ko(model_wxfilename, binary_write);
95 trans_model.
Write(ko.Stream(), binary_write);
96 am_gmm.
Write(ko.Stream(), binary_write);
99 KALDI_LOG <<
"Rescaled model and wrote to " << model_wxfilename;
101 }
catch(
const std::exception &e) {
102 std::cerr << e.what() <<
'\n';
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
BaseFloat min_gaussian_occupancy
Minimum count below which a Gaussian is not updated (and is removed, if remove_low_count_gaussians ==...
double min_variance
Minimum allowed variance in any dimension (if no variance floor) It is in double since the variance i...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
void DoRescalingUpdate(const AccumDiagGmm &old_ml_acc, const AccumDiagGmm &new_ml_acc, BaseFloat min_variance, BaseFloat min_gaussian_occupancy, DiagGmm *gmm, double *tot_count, double *tot_divergence)
void Read(std::istream &is, bool binary)
Configuration variables like variance floor, minimum occupancy, etc.
void Read(std::istream &in_stream, bool binary, bool add=false)
void Write(std::ostream &os, bool binary) const
void Write(std::ostream &out_stream, bool binary) const
void Read(std::istream &in_stream, bool binary)
void Read(std::istream &in, bool binary, bool add=false)
Read function using C++ streams.