30 int32 num_gauss = 5 + rand () % 4;
32 DiagGmm &gmm(*gmm_in);
33 gmm.Resize(num_gauss, dim);
34 Matrix<BaseFloat> inv_vars(num_gauss, dim),
35 means(num_gauss, dim);
36 Vector<BaseFloat> weights(num_gauss);
37 for (
int32 i = 0;
i < num_gauss;
i++) {
44 weights.Scale(1.0 / weights.Sum());
45 gmm.SetWeights(weights);
46 gmm.SetInvVarsAndMeans(inv_vars, means);
51 using namespace kaldi;
58 while (num_splice * raw_dim < model_dim) {
62 int32 full_dim = num_splice * raw_dim;
63 int32 npoints = raw_dim*(raw_dim+1)*10;
66 rand_points.SetRandn();
75 for (
int32 iter = 0; iter < 4; iter++) {
77 for (
int32 i = 0;
i < npoints;
i++) {
87 accs.
Update(opts, &fmllr_mat, &objf_impr, &count);
96 prev_objf_impr = objf_impr;
100 for (
int32 splice = 0; splice < num_splice; splice++) {
103 splice * raw_dim, raw_dim);
104 for (
int32 t = 0; t < npoints; t++) {
119 for (
int i = 0;
i < 2;
i++) {
122 std::cout <<
"Test OK.\n";
void InitRandomGmm(DiagGmm *gmm_in)
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.
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 ...
float RandGauss(struct RandomState *state=NULL)
void SetUnit()
Sets to zero, except ones along diagonal [for non-square matrices too].
void UnitTestFmllrRaw(bool use_offset)
void SetRandn()
Sets to random values of a normal distribution.
int Rand(struct RandomState *state)
#define KALDI_ASSERT(cond)
int32 g_kaldi_verbose_level
This is set by util/parse-options.
Definition for Gaussian Mixture Model with diagonal covariances.
BaseFloat AccumulateForGmm(const DiagGmm &gmm, const VectorBase< BaseFloat > &data, BaseFloat weight)
Accumulate stats for a single GMM in the model; returns log likelihood.
void ApplyAffineTransform(const MatrixBase< BaseFloat > &xform, VectorBase< BaseFloat > *vec)
Applies the affine transform 'xform' to the vector 'vec' and overwrites the contents of 'vec'...
Sub-matrix representation.
Represents a non-allocating general vector which can be defined as a sub-vector of higher-level vecto...