mllt.h
Go to the documentation of this file.
1 // transform/mllt.h
2 
3 // Copyright 2009-2011 Microsoft Corporation
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_TRANSFORM_MLLT_H_
22 #define KALDI_TRANSFORM_MLLT_H_
23 
24 #include <vector>
25 
26 #include "base/kaldi-common.h"
27 #include "gmm/am-diag-gmm.h"
30 #include "util/kaldi-table.h"
31 #include "util/kaldi-holder.h"
32 
33 
34 
35 namespace kaldi {
36 
37 
42 class MlltAccs {
43  public:
44  MlltAccs(): rand_prune_(0.0), beta_(0.0) { }
45 
51  MlltAccs(int32 dim, BaseFloat rand_prune = 0.25) { Init(dim, rand_prune); }
52 
54  void Init(int32 dim, BaseFloat rand_prune = 0.25);
55 
56  void Read(std::istream &is, bool binary, bool add = false);
57 
58  void Write(std::ostream &os, bool binary) const;
59 
60  int32 Dim() { return G_.size(); }; // returns model dimension.
61 
70  BaseFloat *objf_impr_out,
71  BaseFloat *count_out) const {
72  Update(beta_, G_, M, objf_impr_out, count_out);
73  }
74 
75  // A static version of the Update function, so it can
76  // be called externally, given the right stats.
77  static void Update(double beta,
78  const std::vector<SpMatrix<double> > &G,
80  BaseFloat *objf_impr_out,
81  BaseFloat *count_out);
82 
83 
84  void AccumulateFromPosteriors(const DiagGmm &gmm,
85  const VectorBase<BaseFloat> &data,
86  const VectorBase<BaseFloat> &posteriors);
87 
88  // Returns GMM likelihood.
90  const VectorBase<BaseFloat> &data,
91  BaseFloat weight); // e.g. weight = 1.0
92 
94  const std::vector<int32> &gselect,
95  const VectorBase<BaseFloat> &data,
96  BaseFloat weight); // e.g. weight = 1.0
97 
98 
99  // premultiplies the means of the model by M. typically called
100  // after update.
101  // removed since we now do this using different code.
102  // static void MultiplyGmmMeans(const Matrix<BaseFloat> &M,
103  // DiagGmm *gmm);
104 
108  double beta_; // count.
109  std::vector<SpMatrix<double> > G_; // the G matrices (d matrices of size d x d)
110 };
111 
112 } // namespace kaldi
113 
114 #endif // KALDI_TRANSFORM_MLLT_H_
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
MlltAccs(int32 dim, BaseFloat rand_prune=0.25)
Need rand_prune >= 0.
Definition: mllt.h:51
BaseFloat AccumulateFromGmmPreselect(const DiagGmm &gmm, const std::vector< int32 > &gselect, const VectorBase< BaseFloat > &data, BaseFloat weight)
Definition: mllt.cc:173
Base class which provides matrix operations not involving resizing or allocation. ...
Definition: kaldi-matrix.h:49
void Read(std::istream &is, bool binary, bool add=false)
Definition: mllt.cc:34
kaldi::int32 int32
void AccumulateFromPosteriors(const DiagGmm &gmm, const VectorBase< BaseFloat > &data, const VectorBase< BaseFloat > &posteriors)
Definition: mllt.cc:131
void Update(MatrixBase< BaseFloat > *M, BaseFloat *objf_impr_out, BaseFloat *count_out) const
The Update function does the ML update; it requires that M has the right size.
Definition: mllt.h:69
double beta_
Definition: mllt.h:108
std::vector< SpMatrix< double > > G_
Definition: mllt.h:109
void Init(int32 dim, BaseFloat rand_prune=0.25)
initializes (destroys anything that was there before).
Definition: mllt.cc:25
int32 Dim()
Definition: mllt.h:60
BaseFloat rand_prune_
rand_prune_ controls randomized pruning; the larger it is, the more pruning we do.
Definition: mllt.h:107
Definition for Gaussian Mixture Model with diagonal covariances.
Definition: diag-gmm.h:42
BaseFloat AccumulateFromGmm(const DiagGmm &gmm, const VectorBase< BaseFloat > &data, BaseFloat weight)
Definition: mllt.cc:162
Provides a vector abstraction class.
Definition: kaldi-vector.h:41
void Write(std::ostream &os, bool binary) const
Definition: mllt.cc:51
A class for estimating Maximum Likelihood Linear Transform, also known as global Semi-tied Covariance...
Definition: mllt.h:42