24 #ifndef KALDI_GMM_DIAG_GMM_H_ 25 #define KALDI_GMM_DIAG_GMM_H_ 1 66 explicit DiagGmm(
const std::vector<std::pair<BaseFloat, const DiagGmm*> > &gmms);
100 const std::vector<int32> &indices,
108 std::vector<int32> *output)
const;
115 std::vector<std::vector<int32> > *output)
const;
122 const std::vector<int32> &preselect,
124 std::vector<int32> *output)
const;
135 int32 comp_id)
const;
146 void Split(
int32 target_components,
float perturb_factor,
147 std::vector<int32> *history = NULL);
151 void Perturb(
float perturb_factor);
155 void Merge(
int32 target_components, std::vector<int32> *history = NULL);
162 void Write(std::ostream &os,
bool binary)
const;
163 void Read(std::istream &in,
bool binary);
187 void RemoveComponents(
const std::vector<int32> &gauss,
bool renorm_weights);
262 #endif // KALDI_GMM_DIAG_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...
int32 Dim() const
Returns the dimensionality of the Gaussian mean vectors.
void CopyFromDiagGmm(const DiagGmm &diaggmm)
Copies from given DiagGmm.
void Perturb(float perturb_factor)
Perturbs the component means with a random vector multiplied by the pertrub factor.
void Interpolate(BaseFloat rho, const DiagGmm &source, GmmFlagsType flags=kGmmAll)
this = rho x source + (1-rho) x this
void SetInvVarsAndMeans(const MatrixBase< Real > &invvars, const MatrixBase< Real > &means)
Use SetInvVarsAndMeans if updating both means and (inverse) variances.
void Write(std::ostream &os, bool binary) const
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) ...
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.
void Split(int32 target_components, float perturb_factor, std::vector< int32 > *history=NULL)
Split the components and remember the order in which the components were split.
Definition for Gaussian Mixture Model with diagonal covariances in normal mode: where the parameters ...
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
Definition for Gaussian Mixture Model with full covariances.
void GetComponentMean(int32 gauss, VectorBase< Real > *out) const
Accessor for single component mean.
void Resize(int32 nMix, int32 dim)
Resizes arrays to this dim. Does not initialize data.
const Vector< BaseFloat > & gconsts() const
Const accessors.
bool valid_gconsts() const
int32 ComputeGconsts()
Sets the gconsts.
uint16 GmmFlagsType
Bitwise OR of the above flags.
void SetMeans(const MatrixBase< Real > &m)
Use SetMeans to update only the Gaussian means (and not variances)
void SetComponentMean(int32 gauss, const VectorBase< Real > &in)
Mutators for single component, supports float or double Set mean for a single component - internally ...
void GetVars(Matrix< Real > *v) const
Accessor for covariances.
BaseFloat ComponentLogLikelihood(const VectorBase< BaseFloat > &data, int32 comp_id) const
Computes the log-likelihood of a data point given a single Gaussian component.
BaseFloat ComponentPosteriors(const VectorBase< BaseFloat > &data, Vector< BaseFloat > *posteriors) const
Computes the posterior probabilities of all Gaussian components given a data point.
void RemoveComponent(int32 gauss, bool renorm_weights)
Removes single component from model.
BaseFloat LogLikelihood(const VectorBase< BaseFloat > &data) const
Returns the log-likelihood of a data point (vector) given the GMM.
void GetMeans(Matrix< Real > *m) const
Accessor for means.
void RemoveComponents(const std::vector< int32 > &gauss, bool renorm_weights)
Removes multiple components from model; "gauss" must not have dups.
DiagGmm(const DiagGmm &gmm)
bool valid_gconsts_
Recompute gconsts_ if false.
Matrix< BaseFloat > inv_vars_
Inverted (diagonal) variances.
const Vector< BaseFloat > & weights() const
int32 NumGauss() const
Returns the number of mixture components in the GMM.
void LogLikelihoods(const VectorBase< BaseFloat > &data, Vector< BaseFloat > *loglikes) const
Outputs the per-component log-likelihoods.
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.
void MergeKmeans(int32 target_components, ClusterKMeansOptions cfg=ClusterKMeansOptions())
void SetInvVars(const MatrixBase< Real > &v)
Set the (inverse) variances and recompute means_invvars_.
std::istream & operator>>(std::istream &is, Matrix< Real > &M)
void GetComponentVariance(int32 gauss, VectorBase< Real > *out) const
Accessor for single component variance.
void CopyFromFullGmm(const FullGmm &fullgmm)
Copies from given FullGmm.
void Read(std::istream &in, bool binary)
Vector< BaseFloat > weights_
weights (not log).
A class representing a vector.
#define KALDI_ASSERT(cond)
Vector< BaseFloat > gconsts_
Equals log(weight) - 0.5 * (log det(var) + mean*mean*inv(var))
BaseFloat GaussianSelection(const VectorBase< BaseFloat > &data, int32 num_gselect, std::vector< int32 > *output) const
Get gaussian selection information for one frame.
DiagGmm(int32 nMix, int32 dim)
Definition for Gaussian Mixture Model with diagonal covariances.
void Generate(VectorBase< BaseFloat > *output)
Generates a random data-point from this distribution.
void SetComponentInvVar(int32 gauss, const VectorBase< Real > &in)
Set inv-var for single component (recommend to do this before setting the mean, if doing both...
DiagGmm()
Empty constructor.
void SetWeights(const VectorBase< Real > &w)
Mutators for both float or double.
Provides a vector abstraction class.
GaussClusterable wraps Gaussian statistics in a form accessible to generic clustering algorithms...
void CopyFromNormal(const DiagGmmNormal &diag_gmm_normal)
Copies from DiagGmmNormal; does not resize.
Matrix< BaseFloat > means_invvars_
Means times inverted variance.
void SetComponentWeight(int32 gauss, BaseFloat weight)
Set weight for single component.
const Matrix< BaseFloat > & inv_vars() const
BaseFloat merged_components_logdet(BaseFloat w1, BaseFloat w2, const VectorBase< BaseFloat > &f1, const VectorBase< BaseFloat > &f2, const VectorBase< BaseFloat > &s1, const VectorBase< BaseFloat > &s2) const
const DiagGmm & operator=(const DiagGmm &other)