fmllr-sgmm2-test.cc File Reference
#include <vector>
#include "base/kaldi-math.h"
#include "gmm/model-test-common.h"
#include "sgmm2/am-sgmm2.h"
#include "sgmm2/fmllr-sgmm2.h"
#include "util/kaldi-io.h"
Include dependency graph for fmllr-sgmm2-test.cc:

Go to the source code of this file.

Functions

void ApplyFmllrXform (const kaldi::VectorBase< BaseFloat > &in, const Matrix< BaseFloat > &xf, Vector< BaseFloat > *out)
 
void TestSgmm2FmllrAccsIO (const AmSgmm2 &sgmm, const kaldi::Matrix< BaseFloat > &feats)
 
void TestSgmm2FmllrSubspace (const AmSgmm2 &sgmm, const kaldi::Matrix< BaseFloat > &feats)
 
void TestSgmm2Fmllr ()
 
int main ()
 

Function Documentation

◆ ApplyFmllrXform()

void ApplyFmllrXform ( const kaldi::VectorBase< BaseFloat > &  in,
const Matrix< BaseFloat > &  xf,
Vector< BaseFloat > *  out 
)

Definition at line 38 of file fmllr-sgmm2-test.cc.

References VectorBase< Real >::AddMatVec(), VectorBase< Real >::Dim(), KALDI_ASSERT, kaldi::kNoTrans, kaldi::kSetZero, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), and Vector< Real >::Resize().

Referenced by TestSgmm2FmllrAccsIO().

40  {
41  int32 dim = in.Dim();
42  KALDI_ASSERT(xf.NumRows() == dim && xf.NumCols() == dim + 1);
43  Vector<BaseFloat> tmp(dim + 1);
44  tmp.Range(0, dim).CopyFromVec(in);
45  tmp(dim) = 1.0;
46  out->Resize(dim, kaldi::kSetZero);
47  out->AddMatVec(1.0, xf, kaldi::kNoTrans, tmp, 0.0);
48 }
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
Definition: kaldi-matrix.h:67
kaldi::int32 int32
void Resize(MatrixIndexT length, MatrixResizeType resize_type=kSetZero)
Set vector to a specified size (can be zero).
MatrixIndexT Dim() const
Returns the dimension of the vector.
Definition: kaldi-vector.h:64
void AddMatVec(const Real alpha, const MatrixBase< Real > &M, const MatrixTransposeType trans, const VectorBase< Real > &v, const Real beta)
Add matrix times vector : this <– beta*this + alpha*M*v.
Definition: kaldi-vector.cc:92
A class representing a vector.
Definition: kaldi-vector.h:406
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition: kaldi-matrix.h:64

◆ main()

int main ( )

Definition at line 237 of file fmllr-sgmm2-test.cc.

References kaldi::g_kaldi_verbose_level, rnnlm::i, and TestSgmm2Fmllr().

237  {
239  for (int i = 0; i < 10; i++)
240  TestSgmm2Fmllr();
241  std::cout << "Test OK.\n";
242  return 0;
243 }
void TestSgmm2Fmllr()
int32 g_kaldi_verbose_level
This is set by util/parse-options.
Definition: kaldi-error.cc:46

◆ TestSgmm2Fmllr()

void TestSgmm2Fmllr ( )

Definition at line 200 of file fmllr-sgmm2-test.cc.

References AmSgmm2::ComputeNormalizers(), rnnlm::d, kaldi::Exp(), AmSgmm2::InitializeFromFullGmm(), kaldi::unittest::InitRandFullGmm(), kaldi::unittest::RandDiagGaussFeatures(), kaldi::RandGauss(), kaldi::RandInt(), Matrix< Real >::Resize(), MatrixBase< Real >::Row(), TestSgmm2FmllrAccsIO(), and TestSgmm2FmllrSubspace().

Referenced by main().

200  {
201  // srand(time(NULL));
202  int32 dim = 1 + kaldi::RandInt(0, 9); // random dimension of the gmm
203  int32 num_comp = 2 + kaldi::RandInt(0, 9); // random number of mixtures
204  kaldi::FullGmm full_gmm;
205  ut::InitRandFullGmm(dim, num_comp, &full_gmm);
206 
207  AmSgmm2 sgmm;
209  std::vector<int32> pdf2group;
210  pdf2group.push_back(0);
211  sgmm.InitializeFromFullGmm(full_gmm, pdf2group, dim+1, dim, true, 0.9);
212  sgmm.ComputeNormalizers();
213 
215 
216  { // First, generate random means and variances
217  int32 num_feat_comp = num_comp + kaldi::RandInt(-num_comp/2, num_comp/2);
218  kaldi::Matrix<BaseFloat> means(num_feat_comp, dim),
219  vars(num_feat_comp, dim);
220  for (int32 m = 0; m < num_feat_comp; m++) {
221  for (int32 d= 0; d < dim; d++) {
222  means(m, d) = kaldi::RandGauss();
223  vars(m, d) = Exp(kaldi::RandGauss()) + 1e-2;
224  }
225  }
226  // Now generate random features with those means and variances.
227  feats.Resize(num_feat_comp * 200, dim);
228  for (int32 m = 0; m < num_feat_comp; m++) {
229  kaldi::SubMatrix<BaseFloat> tmp(feats, m*200, 200, 0, dim);
230  ut::RandDiagGaussFeatures(200, means.Row(m), vars.Row(m), &tmp);
231  }
232  }
233  TestSgmm2FmllrAccsIO(sgmm, feats);
234  TestSgmm2FmllrSubspace(sgmm, feats);
235 }
double Exp(double x)
Definition: kaldi-math.h:83
Class for definition of the subspace Gmm acoustic model.
Definition: am-sgmm2.h:231
void TestSgmm2FmllrAccsIO(const AmSgmm2 &sgmm, const kaldi::Matrix< BaseFloat > &feats)
Definition for Gaussian Mixture Model with full covariances.
Definition: full-gmm.h:40
void InitializeFromFullGmm(const FullGmm &gmm, const std::vector< int32 > &pdf2group, int32 phn_subspace_dim, int32 spk_subspace_dim, bool speaker_dependent_weights, BaseFloat self_weight)
Initializes the SGMM parameters from a full-covariance UBM.
Definition: am-sgmm2.cc:381
float RandGauss(struct RandomState *state=NULL)
Definition: kaldi-math.h:155
kaldi::int32 int32
void TestSgmm2FmllrSubspace(const AmSgmm2 &sgmm, const kaldi::Matrix< BaseFloat > &feats)
void InitRandFullGmm(int32 dim, int32 num_comp, FullGmm *gmm)
void ComputeNormalizers()
Computes the data-independent terms in the log-likelihood computation for each Gaussian component and...
Definition: am-sgmm2.cc:857
void RandDiagGaussFeatures(int32 num_samples, const VectorBase< BaseFloat > &mean, const VectorBase< BaseFloat > &sqrt_var, MatrixBase< BaseFloat > *feats)
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).
Sub-matrix representation.
Definition: kaldi-matrix.h:988
int32 RandInt(int32 min_val, int32 max_val, struct RandomState *state)
Definition: kaldi-math.cc:95

◆ TestSgmm2FmllrAccsIO()

void TestSgmm2FmllrAccsIO ( const AmSgmm2 sgmm,
const kaldi::Matrix< BaseFloat > &  feats 
)

Definition at line 52 of file fmllr-sgmm2-test.cc.

References FmllrSgmm2Accs::Accumulate(), ApplyFmllrXform(), kaldi::AssertEqual(), AmSgmm2::ComputeFmllrPreXform(), AmSgmm2::ComputePerFrameVars(), AmSgmm2::FeatureDim(), Sgmm2FmllrConfig::fmllr_min_count, Sgmm2GselectConfig::full_gmm_nbest, AmSgmm2::GaussianSelection(), rnnlm::i, FmllrSgmm2Accs::Init(), Sgmm2FmllrGlobalParams::inv_xform_, KALDI_LOG, KALDI_WARN, AmSgmm2::LogLikelihood(), Sgmm2FmllrGlobalParams::mean_scatter_, AmSgmm2::NumGauss(), AmSgmm2::NumGroups(), AmSgmm2::NumPdfs(), MatrixBase< Real >::NumRows(), AmSgmm2::PhoneSpaceDim(), Sgmm2FmllrGlobalParams::pre_xform_, FmllrSgmm2Accs::Read(), Sgmm2PerFrameDerivedVars::Resize(), MatrixBase< Real >::Row(), VectorBase< Real >::Set(), MatrixBase< Real >::SetUnit(), Input::Stream(), FmllrSgmm2Accs::Update(), and FmllrSgmm2Accs::Write().

Referenced by TestSgmm2Fmllr().

53  {
54  KALDI_LOG << "Test IO start.";
55  using namespace kaldi;
56  int32 dim = sgmm.FeatureDim();
59  kaldi::Sgmm2FmllrGlobalParams fmllr_globals;
60  kaldi::Sgmm2GselectConfig sgmm_config;
61 
62  frame_vars.Resize(sgmm.NumGauss(), dim, sgmm.PhoneSpaceDim());
63  sgmm_config.full_gmm_nbest = std::min(sgmm_config.full_gmm_nbest,
64  sgmm.NumGauss());
65  kaldi::Vector<BaseFloat> occs(sgmm.NumPdfs());
66  occs.Set(feats.NumRows());
67  sgmm.ComputeFmllrPreXform(occs, &fmllr_globals.pre_xform_,
68  &fmllr_globals.inv_xform_,
69  &fmllr_globals.mean_scatter_);
70  if (fmllr_globals.mean_scatter_.Min() == 0.0) {
71  KALDI_WARN << "Global covariances low rank!";
72  KALDI_WARN << "Diag-scatter = " << fmllr_globals.mean_scatter_;
73  return;
74  }
75 
76 // std::cout << "Pre-Xform = " << fmllr_globals.pre_xform_;
77 // std::cout << "Inv-Xform = " << fmllr_globals.inv_xform_;
78 
79  FmllrSgmm2Accs accs;
80  accs.Init(sgmm.FeatureDim(), sgmm.NumGauss());
81  BaseFloat loglike = 0.0;
82  std::vector<int32> gselect;
83  for (int32 i = 0; i < feats.NumRows(); i++) {
84  sgmm.GaussianSelection(sgmm_config, feats.Row(i), &gselect);
85  sgmm.ComputePerFrameVars(feats.Row(i), gselect, empty, &frame_vars);
86  loglike += accs.Accumulate(sgmm, feats.Row(i), frame_vars, 0, 1.0,
87  &empty);
88  }
89 
90  kaldi::Sgmm2FmllrConfig update_opts;
91  update_opts.fmllr_min_count = 999; // Make sure it doesn't
92  // divide 200, because the test can fail when we cross the boundary
93  // of 1000 due to roundoff. Actually it's weird because 1000 should
94  // be exactly representable in float and in text. But something's going wrong.
95  kaldi::Matrix<BaseFloat> xform_mat(dim, dim+1);
96  xform_mat.SetUnit();
97  BaseFloat frames, impr;
98  accs.Update(sgmm, fmllr_globals, update_opts, &xform_mat, &frames, &impr);
99 
100  Vector<BaseFloat> xformed_feat(dim);
101  ApplyFmllrXform(feats.Row(0), xform_mat, &xformed_feat);
102  sgmm.GaussianSelection(sgmm_config, xformed_feat, &gselect);
103  sgmm.ComputePerFrameVars(xformed_feat, gselect, empty, &frame_vars);
104 
105  Sgmm2LikelihoodCache like_cache(sgmm.NumGroups(), sgmm.NumPdfs());
106  BaseFloat loglike1 = sgmm.LogLikelihood(frame_vars, 0,
107  &like_cache, &empty);
108 
109  bool binary_in;
110  // First, non-binary write
111  KALDI_LOG << "Test ASCII IO.";
112  accs.Write(kaldi::Output("tmpf", false).Stream(), false);
113  FmllrSgmm2Accs *accs1 = new FmllrSgmm2Accs();
114  // Non-binary read
115  kaldi::Input ki1("tmpf", &binary_in);
116  accs1->Read(ki1.Stream(), binary_in, false);
117  xform_mat.SetUnit();
118  accs1->Update(sgmm, fmllr_globals, update_opts, &xform_mat, NULL, NULL);
119  ApplyFmllrXform(feats.Row(0), xform_mat, &xformed_feat);
120  sgmm.GaussianSelection(sgmm_config, xformed_feat, &gselect);
121  sgmm.ComputePerFrameVars(xformed_feat, gselect, empty, &frame_vars);
122  like_cache.NextFrame();
123  BaseFloat loglike2 = sgmm.LogLikelihood(frame_vars, 0,
124  &like_cache, &empty);
125  std::cout << "LL1 = " << loglike1 << ", LL2 = " << loglike2 << std::endl;
126 
127  kaldi::AssertEqual(loglike1, loglike2, 1e-2);
128  delete accs1;
129 
130  // Next, binary write
131  KALDI_LOG << "Test Binary IO.";
132  accs.Write(kaldi::Output("tmpfb", true).Stream(), true);
133  FmllrSgmm2Accs *accs2 = new FmllrSgmm2Accs();
134  // Binary read
135  kaldi::Input ki2("tmpfb", &binary_in);
136  accs2->Read(ki2.Stream(), binary_in, false);
137  xform_mat.SetUnit();
138  accs2->Update(sgmm, fmllr_globals, update_opts, &xform_mat, NULL, NULL);
139  ApplyFmllrXform(feats.Row(0), xform_mat, &xformed_feat);
140  sgmm.GaussianSelection(sgmm_config, xformed_feat, &gselect);
141  sgmm.ComputePerFrameVars(xformed_feat, gselect, empty, &frame_vars);
142  BaseFloat loglike3 = sgmm.LogLikelihood(frame_vars, 0,
143  &like_cache, &empty);
144  std::cout << "LL1 = " << loglike1 << ", LL3 = " << loglike3 << std::endl;
145  kaldi::AssertEqual(loglike1, loglike3, 1e-4);
146  delete accs2;
147 
148  unlink("tmpf");
149  unlink("tmpfb");
150  KALDI_LOG << "Test IO end.";
151 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
Class for computing the accumulators needed for the maximum-likelihood estimate of FMLLR transforms f...
Definition: fmllr-sgmm2.h:122
Matrix< BaseFloat > pre_xform_
Pre-transform matrix. Dim is [D][D+1].
Definition: fmllr-sgmm2.h:103
void ApplyFmllrXform(const kaldi::VectorBase< BaseFloat > &in, const Matrix< BaseFloat > &xf, Vector< BaseFloat > *out)
kaldi::int32 int32
int32 PhoneSpaceDim() const
Definition: am-sgmm2.h:361
bool Update(const AmSgmm2 &model, const Sgmm2FmllrGlobalParams &fmllr_globals, const Sgmm2FmllrConfig &opts, Matrix< BaseFloat > *out_xform, BaseFloat *frame_count, BaseFloat *auxf_improv) const
Computes the FMLLR transform from the accumulated stats, using the pre-transforms in fmllr_globals...
Definition: fmllr-sgmm2.cc:356
int32 FeatureDim() const
Definition: am-sgmm2.h:363
int32 NumGroups() const
Definition: am-sgmm2.h:351
float BaseFloat
Definition: kaldi-types.h:29
BaseFloat LogLikelihood(const Sgmm2PerFrameDerivedVars &per_frame_vars, int32 j2, Sgmm2LikelihoodCache *cache, Sgmm2PerSpkDerivedVars *spk_vars, BaseFloat log_prune=0.0) const
This does a likelihood computation for a given state using the pre-selected Gaussian components (in p...
Definition: am-sgmm2.cc:517
void Read(std::istream &in_stream, bool binary, bool add)
Definition: fmllr-sgmm2.cc:275
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
Definition: kaldi-matrix.h:188
Matrix< BaseFloat > inv_xform_
Inverse of pre-transform. Dim is [D][D+1].
Definition: fmllr-sgmm2.h:105
BaseFloat GaussianSelection(const Sgmm2GselectConfig &config, const VectorBase< BaseFloat > &data, std::vector< int32 > *gselect) const
Computes the top-scoring Gaussian indices (used for pruning of later stages of computation).
Definition: am-sgmm2.cc:1406
int32 NumPdfs() const
Various model dimensions.
Definition: am-sgmm2.h:350
int32 full_gmm_nbest
Number of highest-scoring full-covariance Gaussians per frame.
Definition: am-sgmm2.h:120
void ComputePerFrameVars(const VectorBase< BaseFloat > &data, const std::vector< int32 > &gselect, const Sgmm2PerSpkDerivedVars &spk_vars, Sgmm2PerFrameDerivedVars *per_frame_vars) const
This needs to be called with each new frame of data, prior to accumulation or likelihood evaluation: ...
Definition: am-sgmm2.cc:442
#define KALDI_WARN
Definition: kaldi-error.h:150
void Resize(int32 ngauss, int32 feat_dim, int32 phn_dim)
Definition: am-sgmm2.h:151
Configuration variables needed in the estimation of FMLLR for SGMMs.
Definition: fmllr-sgmm2.h:40
int32 NumGauss() const
Definition: am-sgmm2.h:360
A class representing a vector.
Definition: kaldi-vector.h:406
BaseFloat Accumulate(const AmSgmm2 &sgmm, const VectorBase< BaseFloat > &data, const Sgmm2PerFrameDerivedVars &frame_vars, int32 state_index, BaseFloat weight, Sgmm2PerSpkDerivedVars *spk)
Accumulation routine that computes the Gaussian posteriors and calls the AccumulateFromPosteriors fun...
Definition: fmllr-sgmm2.cc:156
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition: kaldi-matrix.h:64
void Write(std::ostream &out_stream, bool binary) const
Definition: fmllr-sgmm2.cc:266
void Set(Real f)
Set all members of a vector to a specified value.
static void AssertEqual(float a, float b, float relative_tolerance=0.001)
assert abs(a - b) <= relative_tolerance * (abs(a)+abs(b))
Definition: kaldi-math.h:276
Sgmm2LikelihoodCache caches SGMM likelihoods at two levels: the final pdf likelihoods, and the sub-state level likelihoods, which means that with the SCTM system we can avoid redundant computation.
Definition: am-sgmm2.h:199
Global adaptation parameters.
Definition: fmllr-sgmm2.h:91
Vector< BaseFloat > mean_scatter_
Diagonal of mean-scatter matrix. Dim is [D].
Definition: fmllr-sgmm2.h:107
#define KALDI_LOG
Definition: kaldi-error.h:153
void Init(int32 dim, int32 num_gaussians)
Definition: fmllr-sgmm2.cc:146
Holds the per-frame precomputed quantities x(t), x_{i}(t), z_{i}(t), and n_{i}(t) (cf...
Definition: am-sgmm2.h:142
BaseFloat fmllr_min_count
Minimum occupancy count to estimate FMLLR without basis matrices.
Definition: fmllr-sgmm2.h:46
void ComputeFmllrPreXform(const Vector< BaseFloat > &pdf_occs, Matrix< BaseFloat > *xform, Matrix< BaseFloat > *inv_xform, Vector< BaseFloat > *diag_mean_scatter) const
Computes the LDA-like pre-transform and its inverse as well as the eigenvalues of the scatter of the ...
Definition: am-sgmm2.cc:965

◆ TestSgmm2FmllrSubspace()

void TestSgmm2FmllrSubspace ( const AmSgmm2 sgmm,
const kaldi::Matrix< BaseFloat > &  feats 
)

Definition at line 153 of file fmllr-sgmm2-test.cc.

References FmllrSgmm2Accs::Accumulate(), FmllrSgmm2Accs::AccumulateForFmllrSubspace(), AmSgmm2::ComputeFmllrPreXform(), AmSgmm2::ComputePerFrameVars(), kaldi::EstimateSgmm2FmllrSubspace(), AmSgmm2::FeatureDim(), Sgmm2GselectConfig::full_gmm_nbest, AmSgmm2::GaussianSelection(), rnnlm::i, FmllrSgmm2Accs::Init(), Sgmm2FmllrGlobalParams::inv_xform_, KALDI_LOG, KALDI_WARN, Sgmm2FmllrGlobalParams::mean_scatter_, Sgmm2FmllrConfig::num_fmllr_bases, AmSgmm2::NumGauss(), AmSgmm2::NumPdfs(), MatrixBase< Real >::NumRows(), AmSgmm2::PhoneSpaceDim(), Sgmm2FmllrGlobalParams::pre_xform_, Sgmm2PerFrameDerivedVars::Resize(), MatrixBase< Real >::Row(), VectorBase< Real >::Set(), MatrixBase< Real >::SetUnit(), and FmllrSgmm2Accs::Update().

Referenced by TestSgmm2Fmllr().

154  {
155  KALDI_LOG << "Test Subspace start.";
156  using namespace kaldi;
157  int32 dim = sgmm.FeatureDim();
160  kaldi::Sgmm2FmllrGlobalParams fmllr_globals;
161  kaldi::Sgmm2GselectConfig sgmm_config;
162 
163  frame_vars.Resize(sgmm.NumGauss(), dim, sgmm.PhoneSpaceDim());
164  sgmm_config.full_gmm_nbest = std::min(sgmm_config.full_gmm_nbest,
165  sgmm.NumGauss());
166  kaldi::Vector<BaseFloat> occs(sgmm.NumPdfs());
167  occs.Set(feats.NumRows());
168  sgmm.ComputeFmllrPreXform(occs, &fmllr_globals.pre_xform_,
169  &fmllr_globals.inv_xform_,
170  &fmllr_globals.mean_scatter_);
171  if (fmllr_globals.mean_scatter_.Min() == 0.0) {
172  KALDI_WARN << "Global covariances low rank!";
173  KALDI_WARN << "Diag-scatter = " << fmllr_globals.mean_scatter_;
174  return;
175  }
176 
177  FmllrSgmm2Accs accs;
178  accs.Init(sgmm.FeatureDim(), sgmm.NumGauss());
179  BaseFloat loglike = 0.0;
180  std::vector<int32> gselect;
181  for (int32 i = 0; i < feats.NumRows(); i++) {
182  sgmm.GaussianSelection(sgmm_config, feats.Row(i), &gselect);
183  sgmm.ComputePerFrameVars(feats.Row(i), gselect, empty, &frame_vars);
184  loglike += accs.Accumulate(sgmm, feats.Row(i), frame_vars, 0, 1.0,
185  &empty);
186  }
187 
188  SpMatrix<double> grad_scatter(dim * (dim+1));
189  accs.AccumulateForFmllrSubspace(sgmm, fmllr_globals, &grad_scatter);
190  kaldi::Sgmm2FmllrConfig update_opts;
191  EstimateSgmm2FmllrSubspace(grad_scatter, update_opts.num_fmllr_bases, dim,
192  &fmllr_globals);
193 // update_opts.fmllr_min_count = 100;
194  kaldi::Matrix<BaseFloat> xform_mat(dim, dim+1);
195  xform_mat.SetUnit();
196  accs.Update(sgmm, fmllr_globals, update_opts, &xform_mat, NULL, NULL);
197  KALDI_LOG << "Test Subspace end.";
198 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
Class for computing the accumulators needed for the maximum-likelihood estimate of FMLLR transforms f...
Definition: fmllr-sgmm2.h:122
Matrix< BaseFloat > pre_xform_
Pre-transform matrix. Dim is [D][D+1].
Definition: fmllr-sgmm2.h:103
kaldi::int32 int32
int32 PhoneSpaceDim() const
Definition: am-sgmm2.h:361
void EstimateSgmm2FmllrSubspace(const SpMatrix< double > &fmllr_grad_scatter, int32 num_fmllr_bases, int32 feat_dim, Sgmm2FmllrGlobalParams *globals, double min_eig)
Computes the fMLLR basis matrices given the scatter of the vectorized gradients (eq: B...
Definition: fmllr-sgmm2.cc:506
void AccumulateForFmllrSubspace(const AmSgmm2 &sgmm, const Sgmm2FmllrGlobalParams &fmllr_globals, SpMatrix< double > *grad_scatter)
Definition: fmllr-sgmm2.cc:205
bool Update(const AmSgmm2 &model, const Sgmm2FmllrGlobalParams &fmllr_globals, const Sgmm2FmllrConfig &opts, Matrix< BaseFloat > *out_xform, BaseFloat *frame_count, BaseFloat *auxf_improv) const
Computes the FMLLR transform from the accumulated stats, using the pre-transforms in fmllr_globals...
Definition: fmllr-sgmm2.cc:356
int32 FeatureDim() const
Definition: am-sgmm2.h:363
float BaseFloat
Definition: kaldi-types.h:29
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
Definition: kaldi-matrix.h:188
Matrix< BaseFloat > inv_xform_
Inverse of pre-transform. Dim is [D][D+1].
Definition: fmllr-sgmm2.h:105
BaseFloat GaussianSelection(const Sgmm2GselectConfig &config, const VectorBase< BaseFloat > &data, std::vector< int32 > *gselect) const
Computes the top-scoring Gaussian indices (used for pruning of later stages of computation).
Definition: am-sgmm2.cc:1406
int32 NumPdfs() const
Various model dimensions.
Definition: am-sgmm2.h:350
int32 full_gmm_nbest
Number of highest-scoring full-covariance Gaussians per frame.
Definition: am-sgmm2.h:120
void ComputePerFrameVars(const VectorBase< BaseFloat > &data, const std::vector< int32 > &gselect, const Sgmm2PerSpkDerivedVars &spk_vars, Sgmm2PerFrameDerivedVars *per_frame_vars) const
This needs to be called with each new frame of data, prior to accumulation or likelihood evaluation: ...
Definition: am-sgmm2.cc:442
#define KALDI_WARN
Definition: kaldi-error.h:150
void Resize(int32 ngauss, int32 feat_dim, int32 phn_dim)
Definition: am-sgmm2.h:151
Configuration variables needed in the estimation of FMLLR for SGMMs.
Definition: fmllr-sgmm2.h:40
int32 NumGauss() const
Definition: am-sgmm2.h:360
int32 num_fmllr_bases
Number of basis matrices to use for FMLLR estimation.
Definition: fmllr-sgmm2.h:52
A class representing a vector.
Definition: kaldi-vector.h:406
BaseFloat Accumulate(const AmSgmm2 &sgmm, const VectorBase< BaseFloat > &data, const Sgmm2PerFrameDerivedVars &frame_vars, int32 state_index, BaseFloat weight, Sgmm2PerSpkDerivedVars *spk)
Accumulation routine that computes the Gaussian posteriors and calls the AccumulateFromPosteriors fun...
Definition: fmllr-sgmm2.cc:156
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition: kaldi-matrix.h:64
void Set(Real f)
Set all members of a vector to a specified value.
Global adaptation parameters.
Definition: fmllr-sgmm2.h:91
Vector< BaseFloat > mean_scatter_
Diagonal of mean-scatter matrix. Dim is [D].
Definition: fmllr-sgmm2.h:107
#define KALDI_LOG
Definition: kaldi-error.h:153
void Init(int32 dim, int32 num_gaussians)
Definition: fmllr-sgmm2.cc:146
Holds the per-frame precomputed quantities x(t), x_{i}(t), z_{i}(t), and n_{i}(t) (cf...
Definition: am-sgmm2.h:142
void ComputeFmllrPreXform(const Vector< BaseFloat > &pdf_occs, Matrix< BaseFloat > *xform, Matrix< BaseFloat > *inv_xform, Vector< BaseFloat > *diag_mean_scatter) const
Computes the LDA-like pre-transform and its inverse as well as the eigenvalues of the scatter of the ...
Definition: am-sgmm2.cc:965