48 if (pdf.
Dim() != data.
Dim()) {
50 <<
" vs. model dim = " << pdf.
Dim();
53 KALDI_ERR <<
"State " << (state) <<
": Must call ComputeGconsts() " 54 "before computing likelihood.";
62 for (; it != end; ++it) { it->ApplyPow(2.0); }
67 int32 baseclass, regclass;
68 for (
int32 comp_id = 0, num_comp = pdf.
NumGauss(); comp_id < num_comp;
78 loglikes(comp_id) +=
logdets_(regclass);
83 KALDI_ERR <<
"Invalid answer (overflow or invalid variances/features?)";
98 if (xformed_mean_invvars_.size() != 0)
100 if (xformed_gconsts_.size() != 0)
103 xformed_mean_invvars_.resize(num_pdfs);
104 xformed_gconsts_.resize(num_pdfs);
105 is_cached_.resize(num_pdfs,
false);
125 for (
int32 gauss = 0; gauss < num_gauss; gauss++) {
129 gc += 0.5 *
Log(inv_vars(gauss,
d)) - 0.5 * means(gauss,
d)
130 * means(gauss,
d) * inv_vars(gauss,
d);
135 <<
", not a number in gconst computation";
141 if (gc > 0) gc = -gc;
143 (*gconsts_out)(gauss) = gc;
146 KALDI_WARN << num_bad <<
" unusable components found while computing " 153 if (is_cached_[state]) {
155 KALDI_VLOG(3) <<
"For PDF index " << state <<
": transformed means " 156 <<
"found in cache.";
157 return *xformed_mean_invvars_[state];
160 KALDI_VLOG(3) <<
"For PDF index " << state <<
": transforming means.";
167 xformed_mean_invvars_[state]);
172 xformed_gconsts_[state]);
174 xformed_mean_invvars_[state]->MulElements(invvars);
175 is_cached_[state] =
true;
176 return *xformed_mean_invvars_[state];
182 if (!is_cached_[state]) {
183 KALDI_ERR <<
"GConsts not cached for state: " << state <<
". Must call " 184 <<
"GetXformedMeanInvVars() first.";
187 return *xformed_gconsts_[state];
204 if (pdf.
Dim() != data.
Dim()) {
206 <<
" vs. model dim = " << pdf.
Dim();
226 KALDI_ERR <<
"Invalid answer (overflow or invalid variances/features?)";
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
int32 Dim() const
Returns the dimensionality of the Gaussian mean vectors.
int32 Gauss2BaseclassId(size_t pdf_id, size_t gauss_id) const
void DeletePointers(std::vector< A *> *v)
Deletes any non-NULL pointers in the vector v, and sets the corresponding entries of v to NULL...
std::vector< Vector< BaseFloat > > xformed_data_
BaseFloat log_sum_exp_prune_
void InitCache()
Initializes the mean & gconst caches.
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
Base class which provides matrix operations not involving resizing or allocation. ...
const Matrix< BaseFloat > & means_invvars() const
Vector< BaseFloat > logdets_
virtual BaseFloat LogLikelihoodZeroBased(int32 frame, int32 state_index)
const Vector< BaseFloat > & gconsts() const
Const accessors.
bool valid_gconsts() const
void GetLogDets(VectorBase< BaseFloat > *out) const
Real LogSumExp(Real prune=-1.0) const
Returns log(sum(exp())) without exp overflow If prune > 0.0, ignores terms less than the max - prune...
const RegressionTree & regtree_
Vector< BaseFloat > data_squared_
Cache for fast likelihood calculation.
const RegtreeFmllrDiagGmm & fmllr_xform_
int32 NumRegClasses() const
const AmDiagGmm & acoustic_model_
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
std::vector< Vector< BaseFloat > > xformed_data_squared_
virtual int32 NumIndices() const
Returns the number of states in the acoustic model (they will be indexed one-based, i.e.
const Matrix< BaseFloat > & GetXformedMeanInvVars(int32 state_index)
Get the transformed means times inverse variances for a given pdf, and cache them.
void TransformFeature(const VectorBase< BaseFloat > &in, std::vector< Vector< BaseFloat > > *out) const
Get the transformed features for each of the transforms.
~DecodableAmDiagGmmRegtreeMllr()
const Vector< BaseFloat > & weights() const
int32 NumGauss() const
Returns the number of mixture components in the GMM.
MatrixIndexT Dim() const
Returns the dimension of the vector.
const Matrix< BaseFloat > & feature_matrix_
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.
std::vector< LikelihoodCacheRecord > log_like_cache_
DiagGmm & GetPdf(int32 pdf_index)
Accessors.
A class representing a vector.
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
const Vector< BaseFloat > & GetXformedGconsts(int32 state_index)
Get the cached (while computing transformed means) gconsts for likelihood calculation.
Definition for Gaussian Mixture Model with diagonal covariances.
virtual int32 NumFramesReady() const
The call NumFramesReady() will return the number of frames currently available for this decodable obj...
virtual BaseFloat LogLikelihoodZeroBased(int32 frame, int32 state_index)
Provides a vector abstraction class.
Real VecVec(const VectorBase< Real > &a, const VectorBase< Real > &b)
Returns dot product between v1 and v2.
int32 Base2RegClass(int32 bclass) const
static void ComputeGconsts(const VectorBase< BaseFloat > &weights, const MatrixBase< BaseFloat > &means, const MatrixBase< BaseFloat > &inv_vars, VectorBase< BaseFloat > *gconsts_out)
const Matrix< BaseFloat > & inv_vars() const