24 #ifndef KALDI_GMM_FULL_GMM_H_ 25 #define KALDI_GMM_FULL_GMM_H_ 80 const std::vector<int32> &indices,
88 std::vector<int32> *output)
const;
95 const std::vector<int32> &preselect,
97 std::vector<int32> *output)
const;
108 int32 comp_id)
const;
116 void Split(
int32 target_components,
float perturb_factor,
117 std::vector<int32> *history = NULL);
121 void Perturb(
float perturb_factor);
126 std::vector<int32> *history = NULL);
133 const std::vector<std::pair<int32, int32> > &preselect_pairs);
135 void Write(std::ostream &os,
bool binary)
const;
136 void Read(std::istream &is,
bool binary);
146 const std::vector<SpMatrix<BaseFloat> > &
inv_covars()
const {
191 void RemoveComponents(
const std::vector<int32> &gauss,
bool renorm_weights);
231 #endif // KALDI_GMM_FULL_GMM_H_ std::ostream & operator<<(std::ostream &os, const MatrixBase< Real > &M)
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 Merge(int32 target_components, std::vector< int32 > *history=NULL)
Merge the components and remember the order in which the components were merged (flat list of pairs) ...
const std::vector< SpMatrix< BaseFloat > > & inv_covars() const
BaseFloat ComponentPosteriors(const VectorBase< BaseFloat > &data, VectorBase< BaseFloat > *posterior) const
Computes the posterior probabilities of all Gaussian components given a data point.
int32 Dim() const
Returns the dimensionality of the Gaussian mean vectors.
Definition for Gaussian Mixture Model with full covariances in normal mode: where the parameters are ...
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
void LogLikelihoodsPreselect(const VectorBase< BaseFloat > &data, const std::vector< int32 > &indices, Vector< BaseFloat > *loglikes) const
Outputs the per-component log-likelihoods of a subset of mixture components.
int32 ComputeGconsts()
Sets the gconsts.
void Split(int32 target_components, float perturb_factor, std::vector< int32 > *history=NULL)
Merge the components and remember the order in which the components were merged (flat list of pairs) ...
Definition for Gaussian Mixture Model with full covariances.
std::vector< SpMatrix< BaseFloat > > & inv_covars()
void SetInvCovarsAndMeans(const std::vector< SpMatrix< Real > > &invcovars, const Matrix< Real > &means)
Use SetInvCovarsAndMeans if updating both means and (inverse) covariances.
Vector< BaseFloat > weights_
weights (not log).
void Write(std::ostream &os, bool binary) const
uint16 GmmFlagsType
Bitwise OR of the above flags.
const Vector< BaseFloat > & gconsts() const
Const accessors.
void GetCovars(std::vector< SpMatrix< Real > > *v) const
Accessor for covariances.
FullGmm(const FullGmm &gmm)
void Perturb(float perturb_factor)
Perturbs the component means with a random vector multiplied by the pertrub factor.
void RemoveComponent(int32 gauss, bool renorm_weights)
Mutators for single component, supports float or double Removes single component from model...
FullGmm()
Empty constructor.
void CopyFromFullGmm(const FullGmm &fullgmm)
Copies from given FullGmm.
void Resize(int32 nMix, int32 dim)
Resizes arrays to this dim. Does not initialize data.
void ResizeInvCovars(int32 nMix, int32 dim)
Resizes arrays to this dim. Does not initialize data.
void RemoveComponents(const std::vector< int32 > &gauss, bool renorm_weights)
Removes multiple components from model; "gauss" must not have dups.
bool valid_gconsts_
Recompute gconsts_ if false.
FullGmm(int32 nMix, int32 dim)
BaseFloat GaussianSelectionPreselect(const VectorBase< BaseFloat > &data, const std::vector< int32 > &preselect, int32 num_gselect, std::vector< int32 > *output) const
Get gaussian selection information for one frame.
BaseFloat GaussianSelection(const VectorBase< BaseFloat > &data, int32 num_gselect, std::vector< int32 > *output) const
Get gaussian selection information for one frame.
BaseFloat MergedComponentsLogdet(BaseFloat w1, BaseFloat w2, const VectorBase< BaseFloat > &f1, const VectorBase< BaseFloat > &f2, const SpMatrix< BaseFloat > &s1, const SpMatrix< BaseFloat > &s2) const
int32 NumGauss() const
Returns the number of mixture components in the GMM.
const Vector< BaseFloat > & weights() const
void SetInvCovarsAndMeansInvCovars(const std::vector< SpMatrix< Real > > &invcovars, const Matrix< Real > &means_invcovars)
Use this if setting both, in the class's native format.
void Read(std::istream &is, bool binary)
BaseFloat MergePreselect(int32 target_components, const std::vector< std::pair< int32, int32 > > &preselect_pairs)
Merge the components and remember the order in which the components were merged (flat list of pairs);...
void GetMeans(Matrix< Real > *m) const
Accessor for means.
std::istream & operator>>(std::istream &is, Matrix< Real > &M)
BaseFloat ComponentLogLikelihood(const VectorBase< BaseFloat > &data, int32 comp_id) const
Computes the contribution log-likelihood of a data point from a single Gaussian component.
void SetInvCovars(const std::vector< SpMatrix< Real > > &v)
Set the (inverse) covariances and recompute means_invcovars_.
A class representing a vector.
void LogLikelihoods(const VectorBase< BaseFloat > &data, Vector< BaseFloat > *loglikes) const
Outputs the per-component contributions to the log-likelihood.
void CopyFromDiagGmm(const DiagGmm &diaggmm)
Copies from given DiagGmm.
Definition for Gaussian Mixture Model with diagonal covariances.
std::vector< SpMatrix< BaseFloat > > inv_covars_
Inverse covariances.
void Interpolate(BaseFloat rho, const FullGmm &source, GmmFlagsType flags=kGmmAll)
this = rho x source + (1-rho) x this
const Matrix< BaseFloat > & means_invcovars() const
const FullGmm & operator=(const FullGmm &other)
Provides a vector abstraction class.
Matrix< BaseFloat > means_invcovars_
Means times inverse covariances.
BaseFloat LogLikelihood(const VectorBase< BaseFloat > &data) const
Returns the log-likelihood of a data point (vector) given the GMM.
void SetMeans(const Matrix< Real > &m)
Use SetMeans to update only the Gaussian means (and not variances)
void GetCovarsAndMeans(std::vector< SpMatrix< Real > > *covars, Matrix< Real > *means) const
Accessor for covariances and means.
Matrix< BaseFloat > & means_invcovars()
Non-const accessors.
void GetComponentMean(int32 gauss, VectorBase< Real > *out) const
Accessor for component mean.
Vector< BaseFloat > gconsts_
Equals log(weight) - 0.5 * (log det(var) + mean'*inv(var)*mean)