36 if (tmp.
Cond() < 100)
break;
37 KALDI_LOG <<
"Condition number of random matrix large " 38 <<
static_cast<float>(tmp.
Cond())
39 <<
", trying again (this is normal)\n";
44 if (matrix_sqrt != NULL) matrix_sqrt->
Cholesky(*matrix);
46 if ((matrix_sqrt == NULL) && (logdet == NULL)) {
63 for (
int32 counter = 0; counter < num_samples; counter++) {
67 feats->
Row(counter).CopyFromVec(mean);
68 feats->
Row(counter).AddVecVec(1.0, sqrt_var, rnd_vec, 1.0);
82 for (
int32 counter = 0; counter < num_samples; counter++) {
86 feats->
Row(counter).CopyFromVec(mean);
87 feats->
Row(counter).AddTpVec(1.0, sqrt_var,
kNoTrans, rnd_vec, 1.0);
95 for (
int32 m = 0; m < num_comp; m++) {
104 gmm->
Resize(num_comp, dim);
113 std::vector< SpMatrix<BaseFloat> > invcovars(num_comp);
114 for (
int32 mix = 0; mix < num_comp; mix++) {
115 invcovars[mix].Resize(dim);
119 for (
int32 m = 0; m < num_comp; m++) {
125 invcovars[m].InvertDouble();
126 tot_weight += weights(m);
128 weights.
Scale(1/tot_weight);
130 gmm->
Resize(num_comp, dim);
void AddMat2(const Real alpha, const MatrixBase< Real > &M, MatrixTransposeType transM, const Real beta)
rank-N update: if (transM == kNoTrans) (*this) = beta*(*this) + alpha * M * M^T, or (if transM == kTr...
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void SetWeights(const Vector< Real > &w)
Mutators for both float or double.
Packed symetric matrix class.
void SetInvVarsAndMeans(const MatrixBase< Real > &invvars, const MatrixBase< Real > &means)
Use SetInvVarsAndMeans if updating both means and (inverse) variances.
float RandUniform(struct RandomState *state=NULL)
Returns a random number strictly between 0 and 1.
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
Real Cond() const
Returns condition number by computing Svd.
Base class which provides matrix operations not involving resizing or allocation. ...
int32 ComputeGconsts()
Sets the gconsts.
Definition for Gaussian Mixture Model with full covariances.
void Resize(int32 nMix, int32 dim)
Resizes arrays to this dim. Does not initialize data.
void SetInvCovarsAndMeans(const std::vector< SpMatrix< Real > > &invcovars, const Matrix< Real > &means)
Use SetInvCovarsAndMeans if updating both means and (inverse) covariances.
int32 ComputeGconsts()
Sets the gconsts.
float RandGauss(struct RandomState *state=NULL)
MatrixIndexT NumRows() const
void RandPosdefSpMatrix(int32 dim, SpMatrix< BaseFloat > *matrix, TpMatrix< BaseFloat > *matrix_sqrt, BaseFloat *logdet)
void RandFullGaussFeatures(int32 num_samples, const VectorBase< BaseFloat > &mean, const TpMatrix< BaseFloat > &sqrt_var, MatrixBase< BaseFloat > *feats)
void Cholesky(const SpMatrix< Real > &orig)
void Resize(int32 nMix, int32 dim)
Resizes arrays to this dim. Does not initialize data.
Real LogPosDefDet() const
Computes log determinant but only for +ve-def matrices (it uses Cholesky).
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
void InitRandDiagGmm(int32 dim, int32 num_comp, DiagGmm *gmm)
void SetRandn()
Sets to random values of a normal distribution.
Packed symetric matrix class.
MatrixIndexT Dim() const
Returns the dimension of the vector.
void Scale(Real alpha)
Multiplies all elements by this constant.
Real Sum() const
Returns sum of the elements.
void InitRandFullGmm(int32 dim, int32 num_comp, FullGmm *gmm)
A class representing a vector.
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition for Gaussian Mixture Model with diagonal covariances.
void RandDiagGaussFeatures(int32 num_samples, const VectorBase< BaseFloat > &mean, const VectorBase< BaseFloat > &sqrt_var, MatrixBase< BaseFloat > *feats)
void SetWeights(const VectorBase< Real > &w)
Mutators for both float or double.
Provides a vector abstraction class.