ebw-diag-gmm.h
Go to the documentation of this file.
1 // gmm/ebw-diag-gmm.h
2 
3 // Copyright 2009-2011 Arnab Ghoshal, Petr Motlicek
4 
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 
20 
21 #ifndef KALDI_GMM_EBW_DIAG_GMM_H_
22 #define KALDI_GMM_EBW_DIAG_GMM_H_ 1
23 
24 #include "gmm/diag-gmm.h"
25 #include "gmm/diag-gmm-normal.h"
26 #include "gmm/mle-diag-gmm.h"
27 #include "gmm/mle-am-diag-gmm.h"
28 #include "gmm/model-common.h"
29 #include "itf/options-itf.h"
30 
31 namespace kaldi {
32 
33 // Options for Extended Baum-Welch Gaussian update.
34 struct EbwOptions {
36  BaseFloat tau; // This is only useful for smoothing "to the model":
37  // if you want to smooth to ML stats, you need to use gmm-ismooth-stats
38  EbwOptions(): E(2.0), tau(0.0) { }
39  void Register(OptionsItf *opts) {
40  std::string module = "EbwOptions: ";
41  opts->Register("E", &E, module+"Constant E for Extended Baum-Welch (EBW) update");
42  opts->Register("tau", &tau, module+"Tau value for smoothing to the model "
43  "parameters only (for smoothing to ML stats, use gmm-ismooth-stats");
44  }
45 };
46 
48  BaseFloat min_num_count_weight_update; // minimum numerator count at state level, before we update.
50  BaseFloat tau; // tau value for smoothing stats in weight update. Should probably
51  // be 10.0 or so, leaving it at 0 for back-compatibility.
52  EbwWeightOptions(): min_num_count_weight_update(10.0),
53  min_gaussian_weight(1.0e-05),
54  tau(0.0) { }
55  void Register(OptionsItf *opts) {
56  std::string module = "EbwWeightOptions: ";
57  opts->Register("min-num-count-weight-update", &min_num_count_weight_update,
58  module+"Minimum numerator count required at "
59  "state level before we update the weights (only active if tau == 0.0)");
60  opts->Register("min-gaussian-weight", &min_gaussian_weight,
61  module+"Minimum Gaussian weight allowed in EBW update of weights");
62  opts->Register("weight-tau", &tau,
63  module+"Tau value for smoothing Gaussian weight update.");
64  }
65 };
66 
67 
68 // Update Gaussian parameters only (no weights)
69 // The pointer parameters auxf_change_out etc. are incremented, not set.
70 void UpdateEbwDiagGmm(const AccumDiagGmm &num_stats, // with I-smoothing, if used.
71  const AccumDiagGmm &den_stats,
72  GmmFlagsType flags,
73  const EbwOptions &opts,
74  DiagGmm *gmm,
75  BaseFloat *auxf_change_out,
76  BaseFloat *count_out,
77  int32 *num_floored_out);
78 
79 void UpdateEbwAmDiagGmm(const AccumAmDiagGmm &num_stats, // with I-smoothing, if used.
80  const AccumAmDiagGmm &den_stats,
81  GmmFlagsType flags,
82  const EbwOptions &opts,
83  AmDiagGmm *am_gmm,
84  BaseFloat *auxf_change_out,
85  BaseFloat *count_out,
86  int32 *num_floored_out);
87 
88 // Updates the weights using the EBW-like method described in Dan Povey's thesis
89 // (this method has no tunable parameters).
90 // The pointer parameters auxf_change_out etc. are incremented, not set.
91 void UpdateEbwWeightsDiagGmm(const AccumDiagGmm &num_stats, // should have no I-smoothing
92  const AccumDiagGmm &den_stats,
93  const EbwWeightOptions &opts,
94  DiagGmm *gmm,
95  BaseFloat *auxf_change_out,
96  BaseFloat *count_out);
97 
98 void UpdateEbwWeightsAmDiagGmm(const AccumAmDiagGmm &num_stats, // should have no I-smoothing
99  const AccumAmDiagGmm &den_stats,
100  const EbwWeightOptions &opts,
101  AmDiagGmm *am_gmm,
102  BaseFloat *auxf_change_out,
103  BaseFloat *count_out);
104 
106 void IsmoothStatsDiagGmm(const AccumDiagGmm &src_stats,
107  double tau,
108  AccumDiagGmm *dst_stats);
109 
111 void DiagGmmToStats(const DiagGmm &gmm,
112  GmmFlagsType flags,
113  double state_occ,
114  AccumDiagGmm *dst_stats);
115 
118 void IsmoothStatsAmDiagGmm(const AccumAmDiagGmm &src_stats,
119  double tau,
120  AccumAmDiagGmm *dst_stats);
121 
123 void IsmoothStatsAmDiagGmmFromModel(const AmDiagGmm &src_model,
124  double tau,
125  AccumAmDiagGmm *dst_stats);
126 
127 
128 
129 } // End namespace kaldi
130 
131 
132 #endif // KALDI_GMM_EBW_DIAG_GMM_H_
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void UpdateEbwWeightsDiagGmm(const AccumDiagGmm &num_stats, const AccumDiagGmm &den_stats, const EbwWeightOptions &opts, DiagGmm *gmm, BaseFloat *auxf_change_out, BaseFloat *count_out)
kaldi::int32 int32
uint16 GmmFlagsType
Bitwise OR of the above flags.
Definition: model-common.h:35
void IsmoothStatsDiagGmm(const AccumDiagGmm &src_stats, double tau, AccumDiagGmm *dst_stats)
I-Smooth the stats. src_stats and dst_stats do not have to be different.
void UpdateEbwDiagGmm(const AccumDiagGmm &num_stats, const AccumDiagGmm &den_stats, GmmFlagsType flags, const EbwOptions &opts, DiagGmm *gmm, BaseFloat *auxf_change_out, BaseFloat *count_out, int32 *num_floored_out)
Definition: ebw-diag-gmm.cc:94
virtual void Register(const std::string &name, bool *ptr, const std::string &doc)=0
void UpdateEbwWeightsAmDiagGmm(const AccumAmDiagGmm &num_stats, const AccumAmDiagGmm &den_stats, const EbwWeightOptions &opts, AmDiagGmm *am_gmm, BaseFloat *auxf_change_out, BaseFloat *count_out)
void IsmoothStatsAmDiagGmmFromModel(const AmDiagGmm &src_model, double tau, AccumAmDiagGmm *dst_stats)
This version of the I-smoothing function takes a model as input.
void IsmoothStatsAmDiagGmm(const AccumAmDiagGmm &src_stats, double tau, AccumAmDiagGmm *dst_stats)
Smooth "dst_stats" with "src_stats".
void Register(OptionsItf *opts)
Definition: ebw-diag-gmm.h:55
BaseFloat min_num_count_weight_update
Definition: ebw-diag-gmm.h:48
BaseFloat min_gaussian_weight
Definition: ebw-diag-gmm.h:49
Definition for Gaussian Mixture Model with diagonal covariances.
Definition: diag-gmm.h:42
void UpdateEbwAmDiagGmm(const AccumAmDiagGmm &num_stats, const AccumAmDiagGmm &den_stats, GmmFlagsType flags, const EbwOptions &opts, AmDiagGmm *am_gmm, BaseFloat *auxf_change_out, BaseFloat *count_out, int32 *num_floored_out)
void Register(OptionsItf *opts)
Definition: ebw-diag-gmm.h:39
void DiagGmmToStats(const DiagGmm &gmm, GmmFlagsType flags, double state_occ, AccumDiagGmm *dst_stats)
Creates stats from the GMM. Resizes them as needed.