31 KALDI_ASSERT(default_class >= 0 && default_class < num_classes);
32 A_.resize(num_classes);
33 for (
int32 i = 0;
i < num_classes;
i++) {
34 A_[
i].Resize(dim, dim);
40 warps_.resize(num_classes, 1.0);
54 A_[
i].Read(is, binary);
62 if (token ==
"</LinearVtln>") {
76 if(!binary) os <<
"\n";
83 A_[
i].Write(os, binary);
88 if(!binary) os <<
"\n";
98 std::string norm_type,
107 if (norm_type !=
"none" && norm_type !=
"offset" && norm_type !=
"diag")
108 KALDI_ERR <<
"LinearVtln::ComputeTransform, norm_type should be " 109 "one of \"none\", \"offset\" or \"diag\"";
111 if (accs.
beta_ == 0.0) {
112 KALDI_WARN <<
"no stats, returning default transform";
117 Ws->
Range(0, dim, dim, 1).SetZero();
121 if (objf_impr) *objf_impr = 0;
122 if (count) *count = 0;
129 best_objf = -1.0e+100;
130 int32 best_class = -1;
147 if (logdet_scale != 1.0)
150 if (objf > best_objf) {
158 if (class_idx) *class_idx = best_class;
159 if (logdet_out) *logdet_out =
logdets_[best_class];
160 if (objf_impr) *objf_impr = best_objf - old_objf;
161 if (count) *count = accs.
beta_;
170 A_[
i].CopyFromMat(transform);
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
BaseFloat GetWarp(int32 i) const
void SetTransform(int32 i, const MatrixBase< BaseFloat > &transform)
std::vector< Matrix< BaseFloat > > A_
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
Base class which provides matrix operations not involving resizing or allocation. ...
void ReadBasicType(std::istream &is, bool binary, T *t)
ReadBasicType is the name of the read function for bool, integer types, and floating-point types...
This does not work with multiple feature transforms.
void ReadToken(std::istream &is, bool binary, std::string *str)
ReadToken gets the next token and puts it in str (exception on failure).
void CopyFromMat(const MatrixBase< OtherReal > &M, MatrixTransposeType trans=kNoTrans)
Copy given matrix. (no resize is done).
void SetUnit()
Sets to zero, except ones along diagonal [for non-square matrices too].
void ApplyFeatureTransformToStats(const MatrixBase< BaseFloat > &xform, AffineXformStats *stats)
This function applies a feature-level transform to stats (useful for certain techniques based on fMLL...
void GetTransform(int32 i, MatrixBase< BaseFloat > *transform) const
void Read(std::istream &is, bool binary)
void ComputeTransform(const FmllrDiagGmmAccs &accs, std::string norm_type, BaseFloat logdet_scale, MatrixBase< BaseFloat > *Ws, int32 *class_idx, BaseFloat *logdet_out, BaseFloat *objf_impr=NULL, BaseFloat *count=NULL)
Compute the transform for the speaker.
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
void SetWarp(int32 i, BaseFloat warp)
std::vector< BaseFloat > warps_
BaseFloat ComputeFmllrMatrixDiagGmm(const MatrixBase< BaseFloat > &in_xform, const AffineXformStats &stats, std::string fmllr_type, int32 num_iters, MatrixBase< BaseFloat > *out_xform)
This function internally calls ComputeFmllrMatrixDiagGmm{Full, Diagonal, Offset}, depending on "fmllr...
bool ComposeTransforms(const Matrix< BaseFloat > &a, const Matrix< BaseFloat > &b, bool b_is_affine, Matrix< BaseFloat > *c)
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
float FmllrAuxFuncDiagGmm(const MatrixBase< float > &xform, const AffineXformStats &stats)
Returns the (diagonal-GMM) FMLLR auxiliary function value given the transform and the stats...
void Write(std::ostream &os, bool binary) const
SubMatrix< Real > Range(const MatrixIndexT row_offset, const MatrixIndexT num_rows, const MatrixIndexT col_offset, const MatrixIndexT num_cols) const
Return a sub-part of matrix.
void WriteBasicType(std::ostream &os, bool binary, T t)
WriteBasicType is the name of the write function for bool, integer types, and floating-point types...
std::vector< BaseFloat > logdets_