#include <fmllr-raw.h>
Classes | |
struct | SingleFrameStats |
Public Member Functions | |
FmllrRawAccs () | |
int32 | RawDim () const |
Dimension of raw MFCC (etc.) features. More... | |
int32 | FullDim () const |
Full feature dimension after splicing. More... | |
int32 | SpliceWidth () const |
Number of frames that are spliced together each time. More... | |
int32 | ModelDim () const |
Dimension of the model. More... | |
FmllrRawAccs (int32 raw_dim, int32 model_dim, const Matrix< BaseFloat > &full_transform) | |
BaseFloat | AccumulateForGmm (const DiagGmm &gmm, const VectorBase< BaseFloat > &data, BaseFloat weight) |
Accumulate stats for a single GMM in the model; returns log likelihood. More... | |
void | AccumulateFromPosteriors (const DiagGmm &gmm, const VectorBase< BaseFloat > &data, const VectorBase< BaseFloat > &posteriors) |
Accumulate stats for a GMM, given supplied posteriors. More... | |
void | Update (const FmllrRawOptions &opts, MatrixBase< BaseFloat > *raw_fmllr_mat, BaseFloat *objf_impr, BaseFloat *count) |
Update "raw_fmllr_mat"; it should have the correct dimension and reasonable values at entry (see the function InitFmllr in fmllr-diag-gmm.h for how to initialize it.) The only reason this function is not const is because we may have to call CommitSingleFrameStats(). More... | |
void | SetZero () |
Private Member Functions | |
void | CommitSingleFrameStats () |
void | InitSingleFrameStats (const VectorBase< BaseFloat > &data) |
bool | DataHasChanged (const VectorBase< BaseFloat > &data) const |
double | GetAuxf (const Vector< double > &simple_linear_stats, const SpMatrix< double > &simple_quadratic_stats, const Matrix< double > &fmllr_mat) const |
Compute the auxiliary function for this matrix. More... | |
void | ConvertToSimpleStats (Vector< double > *simple_linear_stats, SpMatrix< double > *simple_quadratic_stats) const |
Converts from the Q and S stats to a simple objective function of the form l . More... | |
void | ComputeM (std::vector< Matrix< double > > *M) const |
Computes the M_i matrices used in the update, see the extended comment in fmllr-raw.cc for explanation. More... | |
void | ConvertToPerRowStats (const Vector< double > &simple_linear_stats, const SpMatrix< double > &simple_quadratic_stats_sp, Matrix< double > *linear_stats, std::vector< SpMatrix< double > > *diag_stats, std::vector< std::vector< Matrix< double > > > *off_diag_stats) const |
Transform stats into a convenient format for the update. More... | |
KALDI_DISALLOW_COPY_AND_ASSIGN (FmllrRawAccs) | |
Private Attributes | |
int32 | raw_dim_ |
int32 | model_dim_ |
Matrix< BaseFloat > | full_transform_ |
Vector< BaseFloat > | transform_offset_ |
SingleFrameStats | single_frame_stats_ |
double | count_ |
SpMatrix< double > | temp_ |
Matrix< double > | Q_ |
Matrix< double > | S_ |
Definition at line 81 of file fmllr-raw.h.
|
inline |
Definition at line 83 of file fmllr-raw.h.
FmllrRawAccs | ( | int32 | raw_dim, |
int32 | model_dim, | ||
const Matrix< BaseFloat > & | full_transform | ||
) |
Definition at line 29 of file fmllr-raw.cc.
References FmllrRawAccs::SingleFrameStats::a, FmllrRawAccs::SingleFrameStats::b, FmllrRawAccs::SingleFrameStats::count, FmllrRawAccs::count_, FmllrRawAccs::full_transform_, KALDI_ERR, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), FmllrRawAccs::Q_, MatrixBase< Real >::Range(), SpMatrix< Real >::Resize(), Vector< Real >::Resize(), Matrix< Real >::Resize(), FmllrRawAccs::SingleFrameStats::s, FmllrRawAccs::S_, FmllrRawAccs::single_frame_stats_, FmllrRawAccs::temp_, FmllrRawAccs::transform_offset_, and FmllrRawAccs::SingleFrameStats::transformed_data.
BaseFloat AccumulateForGmm | ( | const DiagGmm & | gmm, |
const VectorBase< BaseFloat > & | data, | ||
BaseFloat | weight | ||
) |
Accumulate stats for a single GMM in the model; returns log likelihood.
Here, "data" will typically be of larger dimension than the model. Note: "data" is the original, spliced features– before LDA+MLLT. Returns log-like for this data given this GMM, including rejected dimensions (not multiplied by weight).
Definition at line 107 of file fmllr-raw.cc.
References FmllrRawAccs::AccumulateFromPosteriors(), FmllrRawAccs::CommitSingleFrameStats(), DiagGmm::ComponentPosteriors(), FmllrRawAccs::DataHasChanged(), VectorBase< Real >::Dim(), FmllrRawAccs::FullDim(), FmllrRawAccs::InitSingleFrameStats(), KALDI_ASSERT, M_LOG_2PI, FmllrRawAccs::ModelDim(), DiagGmm::NumGauss(), VectorBase< Real >::Scale(), FmllrRawAccs::single_frame_stats_, FmllrRawAccs::SingleFrameStats::transformed_data, and kaldi::VecVec().
Referenced by kaldi::AccStatsForUtterance(), and kaldi::UnitTestFmllrRaw().
void AccumulateFromPosteriors | ( | const DiagGmm & | gmm, |
const VectorBase< BaseFloat > & | data, | ||
const VectorBase< BaseFloat > & | posteriors | ||
) |
Accumulate stats for a GMM, given supplied posteriors.
Note: "data" is the original, spliced features– before LDA+MLLT.
Definition at line 246 of file fmllr-raw.cc.
References FmllrRawAccs::SingleFrameStats::a, VectorBase< Real >::AddVec(), VectorBase< Real >::AddVecVec(), FmllrRawAccs::SingleFrameStats::b, FmllrRawAccs::CommitSingleFrameStats(), count, FmllrRawAccs::SingleFrameStats::count, FmllrRawAccs::DataHasChanged(), FmllrRawAccs::InitSingleFrameStats(), DiagGmm::inv_vars(), DiagGmm::means_invvars(), FmllrRawAccs::ModelDim(), DiagGmm::NumGauss(), MatrixBase< Real >::Row(), FmllrRawAccs::single_frame_stats_, and FmllrRawAccs::transform_offset_.
Referenced by kaldi::AccStatsForUtterance(), and FmllrRawAccs::AccumulateForGmm().
|
private |
Definition at line 68 of file fmllr-raw.cc.
References FmllrRawAccs::SingleFrameStats::a, SpMatrix< Real >::AddVec2(), MatrixBase< Real >::AddVecVec(), FmllrRawAccs::SingleFrameStats::b, FmllrRawAccs::SingleFrameStats::count, FmllrRawAccs::count_, PackedMatrix< Real >::Data(), FmllrRawAccs::FullDim(), FmllrRawAccs::ModelDim(), FmllrRawAccs::Q_, VectorBase< Real >::Range(), FmllrRawAccs::SingleFrameStats::s, FmllrRawAccs::S_, PackedMatrix< Real >::SetZero(), FmllrRawAccs::single_frame_stats_, and FmllrRawAccs::temp_.
Referenced by FmllrRawAccs::AccumulateForGmm(), FmllrRawAccs::AccumulateFromPosteriors(), and FmllrRawAccs::Update().
|
private |
Computes the M_i matrices used in the update, see the extended comment in fmllr-raw.cc for explanation.
Definition at line 412 of file fmllr-raw.cc.
References FmllrRawAccs::full_transform_, FmllrRawAccs::FullDim(), rnnlm::i, rnnlm::j, and FmllrRawAccs::RawDim().
Referenced by FmllrRawAccs::ConvertToSimpleStats().
|
private |
Transform stats into a convenient format for the update.
linear_stats is of dim RawDim() by RawDim() + 1, it's the linear term. diag_stats (of dimension RawDim(), each element of dimension RawDim() + 1 is the quadratic terms w.r.t. the diagonals. off_diag_stats contains the cross-terms between different rows; it is indexed [i][j], with 0 <= i < RawDim(), and j < i, and each element is of dimension RawDim() + 1 by RawDim() + 1. The [i][j]'th element is interpreted as follows: the inner product with the [i'th row] [element [i][j]] [j'th row] is the term in the objective function. This function resizes its output.
Definition at line 493 of file fmllr-raw.cc.
References MatrixBase< Real >::CopyRowsFromVec(), rnnlm::i, rnnlm::j, kaldi::kTakeMean, FmllrRawAccs::RawDim(), and Matrix< Real >::Resize().
Referenced by FmllrRawAccs::Update().
|
private |
Converts from the Q and S stats to a simple objective function of the form l .
simple_linear_stats -0.5 l^t simple_quadratic_stats l, plus the determinant term, where l is the linearized transform.
Definition at line 455 of file fmllr-raw.cc.
References VectorBase< Real >::AddMatVec(), SpMatrix< Real >::AddSmat2Sp(), FmllrRawAccs::ComputeM(), VectorBase< Real >::CopyFromVec(), PackedMatrix< Real >::Data(), FmllrRawAccs::FullDim(), rnnlm::i, kaldi::kNoTrans, FmllrRawAccs::ModelDim(), FmllrRawAccs::Q_, FmllrRawAccs::RawDim(), SpMatrix< Real >::Resize(), Vector< Real >::Resize(), MatrixBase< Real >::Row(), FmllrRawAccs::S_, VectorBase< Real >::Scale(), and FmllrRawAccs::transform_offset_.
Referenced by FmllrRawAccs::Update().
|
private |
Definition at line 63 of file fmllr-raw.cc.
References VectorBase< Real >::ApproxEqual(), VectorBase< Real >::Dim(), FmllrRawAccs::FullDim(), KALDI_ASSERT, FmllrRawAccs::SingleFrameStats::s, and FmllrRawAccs::single_frame_stats_.
Referenced by FmllrRawAccs::AccumulateForGmm(), and FmllrRawAccs::AccumulateFromPosteriors().
|
inline |
Full feature dimension after splicing.
Definition at line 88 of file fmllr-raw.h.
Referenced by FmllrRawAccs::AccumulateForGmm(), FmllrRawAccs::CommitSingleFrameStats(), FmllrRawAccs::ComputeM(), FmllrRawAccs::ConvertToSimpleStats(), FmllrRawAccs::DataHasChanged(), and FmllrRawAccs::InitSingleFrameStats().
|
private |
Compute the auxiliary function for this matrix.
Definition at line 529 of file fmllr-raw.cc.
References VectorBase< Real >::CopyRowsFromMat(), FmllrRawAccs::count_, MatrixBase< Real >::LogDet(), FmllrRawAccs::RawDim(), FmllrRawAccs::SpliceWidth(), kaldi::VecSpVec(), and kaldi::VecVec().
Referenced by FmllrRawAccs::Update().
|
private |
Definition at line 93 of file fmllr-raw.cc.
References FmllrRawAccs::SingleFrameStats::a, FmllrRawAccs::SingleFrameStats::b, FmllrRawAccs::SingleFrameStats::count, VectorBase< Real >::Dim(), FmllrRawAccs::full_transform_, FmllrRawAccs::FullDim(), KALDI_ASSERT, kaldi::kNoTrans, FmllrRawAccs::SingleFrameStats::s, VectorBase< Real >::SetZero(), FmllrRawAccs::single_frame_stats_, FmllrRawAccs::transform_offset_, and FmllrRawAccs::SingleFrameStats::transformed_data.
Referenced by FmllrRawAccs::AccumulateForGmm(), and FmllrRawAccs::AccumulateFromPosteriors().
|
private |
|
inline |
Dimension of the model.
Definition at line 92 of file fmllr-raw.h.
References count.
Referenced by FmllrRawAccs::AccumulateForGmm(), FmllrRawAccs::AccumulateFromPosteriors(), FmllrRawAccs::CommitSingleFrameStats(), and FmllrRawAccs::ConvertToSimpleStats().
|
inline |
Dimension of raw MFCC (etc.) features.
Definition at line 86 of file fmllr-raw.h.
Referenced by FmllrRawAccs::ComputeM(), FmllrRawAccs::ConvertToPerRowStats(), FmllrRawAccs::ConvertToSimpleStats(), FmllrRawAccs::GetAuxf(), and FmllrRawAccs::Update().
void SetZero | ( | ) |
Definition at line 402 of file fmllr-raw.cc.
References FmllrRawAccs::SingleFrameStats::count, FmllrRawAccs::count_, FmllrRawAccs::Q_, FmllrRawAccs::SingleFrameStats::s, FmllrRawAccs::S_, MatrixBase< Real >::SetZero(), and FmllrRawAccs::single_frame_stats_.
Referenced by kaldi::UnitTestFmllrRaw().
|
inline |
Number of frames that are spliced together each time.
Definition at line 90 of file fmllr-raw.h.
Referenced by FmllrRawAccs::GetAuxf(), and FmllrRawAccs::Update().
void Update | ( | const FmllrRawOptions & | opts, |
MatrixBase< BaseFloat > * | raw_fmllr_mat, | ||
BaseFloat * | objf_impr, | ||
BaseFloat * | count | ||
) |
Update "raw_fmllr_mat"; it should have the correct dimension and reasonable values at entry (see the function InitFmllr in fmllr-diag-gmm.h for how to initialize it.) The only reason this function is not const is because we may have to call CommitSingleFrameStats().
Definition at line 299 of file fmllr-raw.cc.
References VectorBase< Real >::AddMatVec(), FmllrRawAccs::CommitSingleFrameStats(), FmllrRawAccs::ConvertToPerRowStats(), FmllrRawAccs::ConvertToSimpleStats(), MatrixBase< Real >::CopyFromMat(), VectorBase< Real >::CopyFromVec(), FmllrRawAccs::SingleFrameStats::count, FmllrRawAccs::count_, kaldi::FmllrInnerUpdate(), FmllrRawAccs::GetAuxf(), kaldi::GetVerboseLevel(), rnnlm::i, MatrixBase< Real >::IsZero(), KALDI_ASSERT, KALDI_VLOG, KALDI_WARN, kaldi::kNoTrans, kaldi::kTrans, FmllrRawOptions::min_count, FmllrRawOptions::num_iters, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), FmllrRawAccs::RawDim(), MatrixBase< Real >::Row(), FmllrRawAccs::single_frame_stats_, and FmllrRawAccs::SpliceWidth().
Referenced by kaldi::UnitTestFmllrRaw().
|
private |
Definition at line 190 of file fmllr-raw.h.
Referenced by FmllrRawAccs::CommitSingleFrameStats(), FmllrRawAccs::FmllrRawAccs(), FmllrRawAccs::GetAuxf(), FmllrRawAccs::SetZero(), and FmllrRawAccs::Update().
Definition at line 183 of file fmllr-raw.h.
Referenced by FmllrRawAccs::ComputeM(), FmllrRawAccs::FmllrRawAccs(), and FmllrRawAccs::InitSingleFrameStats().
|
private |
Definition at line 181 of file fmllr-raw.h.
|
private |
Definition at line 195 of file fmllr-raw.h.
Referenced by FmllrRawAccs::CommitSingleFrameStats(), FmllrRawAccs::ConvertToSimpleStats(), FmllrRawAccs::FmllrRawAccs(), and FmllrRawAccs::SetZero().
|
private |
Definition at line 180 of file fmllr-raw.h.
|
private |
Definition at line 196 of file fmllr-raw.h.
Referenced by FmllrRawAccs::CommitSingleFrameStats(), FmllrRawAccs::ConvertToSimpleStats(), FmllrRawAccs::FmllrRawAccs(), and FmllrRawAccs::SetZero().
|
private |
Definition at line 188 of file fmllr-raw.h.
Referenced by FmllrRawAccs::AccumulateForGmm(), FmllrRawAccs::AccumulateFromPosteriors(), FmllrRawAccs::CommitSingleFrameStats(), FmllrRawAccs::DataHasChanged(), FmllrRawAccs::FmllrRawAccs(), FmllrRawAccs::InitSingleFrameStats(), FmllrRawAccs::SetZero(), and FmllrRawAccs::Update().
|
private |
Definition at line 194 of file fmllr-raw.h.
Referenced by FmllrRawAccs::CommitSingleFrameStats(), and FmllrRawAccs::FmllrRawAccs().
Definition at line 185 of file fmllr-raw.h.
Referenced by FmllrRawAccs::AccumulateFromPosteriors(), FmllrRawAccs::ConvertToSimpleStats(), FmllrRawAccs::FmllrRawAccs(), and FmllrRawAccs::InitSingleFrameStats().