Interface of full GMM computation with integer value of log likelihood. More...
#include <s3types.h>
#include <logmath.h>
Go to the source code of this file.
Classes | |
struct | mgau_t |
A single mixture-Gaussian model for one senone (see above comment). More... | |
struct | mgau_model_t |
The set of mixture-Gaussians in an acoustic model used in Sphinx 3.X family of tool. More... | |
Defines | |
#define | CONTHMM 10001 |
#define | SEMIHMM 10002 |
#define | FULL_INT_COMP 20001 |
#define | FULL_FLOAT_COMP 20002 |
#define | MIX_INT_FLOAT_COMP 20003 |
#define | MGAU_MEAN 1 |
#define | MGAU_VAR 2 |
#define | MGAU_FULLVAR 3 |
#define | NO_BSTIDX -1 |
#define | NOT_UPDATED -100 |
#define | mgau_n_mgau(g) ((g)->n_mgau) |
#define | mgau_max_comp(g) ((g)->max_comp) |
#define | mgau_veclen(g) ((g)->veclen) |
#define | mgau_n_comp(g, m) ((g)->mgau[m].n_comp) |
#define | mgau_mean(g, m, c) ((g)->mgau[m].mean[c]) |
#define | mgau_var(g, m, c) ((g)->mgau[m].var[c]) |
#define | mgau_fullvar(g, m, c) ((g)->mgau[m].fullvar[c]) |
#define | mgau_mixw(g, m, c) ((g)->mgau[m].mixw[c]) |
#define | mgau_mixw_f(g, m, c) ((g)->mgau[m].mixw_f[c]) |
#define | mgau_lrd(g, m, c) ((g)->mgau[m].lrd[c]) |
#define | mgau_lrdi(g, m, c) ((g)->mgau[m].lrdi[c]) |
#define | mgau_frm_sen_eval(g) ((g)->frm_sen_eval) |
#define | mgau_frm_gau_eval(g) ((g)->frm_gau_eval) |
#define | mgau_frm_cisen_eval(g) ((g)->frm_ci_sen_eval) |
#define | mgau_frm_cigau_eval(g) ((g)->frm_ci_gau_eval) |
Functions | |
S3DECODER_EXPORT mgau_model_t * | mgau_init (const char *meanfile, const char *varfile, float64 varfloor, const char *mixwfile, float64 mixwfloor, int32 precomp, const char *senmgau, int32 comp_type, logmath_t *logmath) |
int32 | mgau_var_nzvec_floor (mgau_model_t *g, float64 floor) |
S3DECODER_EXPORT int32 | mgau_eval (mgau_model_t *g, int32 m, int32 *active_comp, float32 *x, int32 fr, int32 bUpdBstIdx) |
S3DECODER_EXPORT int32 | mgau_comp_eval (mgau_model_t *g, int32 s, float32 *x, int32 *score) |
int32 | mgau_dump (mgau_model_t *g, int32 type) |
S3DECODER_EXPORT void | mgau_free (mgau_model_t *g) |
S3DECODER_EXPORT int32 | mgau_mean_reload (mgau_model_t *g, const char *mean_file_name) |
Interface of full GMM computation with integer value of log likelihood.
#define CONTHMM 10001 |
Specification of sets of GMM
Referenced by mgau_init().
#define FULL_FLOAT_COMP 20002 |
Referenced by mgau_init().
#define FULL_INT_COMP 20001 |
Referenced by mgau_init().
#define mgau_frm_cigau_eval | ( | g | ) | ((g)->frm_ci_gau_eval) |
Number of CI gaussians evaluated in this frame
#define mgau_frm_cisen_eval | ( | g | ) | ((g)->frm_ci_sen_eval) |
Number of CI senones evaluated in this frame
#define mgau_frm_gau_eval | ( | g | ) | ((g)->frm_gau_eval) |
Number of gaussians evaluated in this frame
#define mgau_frm_sen_eval | ( | g | ) | ((g)->frm_sen_eval) |
Number of senones evaluated in this frame
#define mgau_fullvar | ( | g, | |||
m, | |||||
c | ) | ((g)->mgau[m].fullvar[c]) |
#define MGAU_FULLVAR 3 |
#define mgau_lrd | ( | g, | |||
m, | |||||
c | ) | ((g)->mgau[m].lrd[c]) |
Access the floating point version of the Gaussian constant
Access the integer version of the Gaussian constant
#define mgau_lrdi | ( | g, | |||
m, | |||||
c | ) | ((g)->mgau[m].lrdi[c]) |
#define mgau_max_comp | ( | g | ) | ((g)->max_comp) |
Access the maximum number of components. It can be different across GMMs
Referenced by main().
#define mgau_mean | ( | g, | |||
m, | |||||
c | ) | ((g)->mgau[m].mean[c]) |
Access the mean
#define MGAU_MEAN 1 |
Referenced by mgau_dump(), mgau_init(), and mgau_mean_reload().
#define mgau_mixw | ( | g, | |||
m, | |||||
c | ) | ((g)->mgau[m].mixw[c]) |
#define mgau_mixw_f | ( | g, | |||
m, | |||||
c | ) | ((g)->mgau[m].mixw_f[c]) |
#define mgau_n_comp | ( | g, | |||
m | ) | ((g)->mgau[m].n_comp) |
Access the number of component for a particular mixture in a GMM
Referenced by approx_cont_mgau_ci_eval(), main(), mgau_dump(), and mgau_var_nzvec_floor().
#define mgau_n_mgau | ( | g | ) | ((g)->n_mgau) |
Access macros Access number of GMMs
Referenced by main(), mgau_dump(), and mgau_var_nzvec_floor().
#define mgau_var | ( | g, | |||
m, | |||||
c | ) | ((g)->mgau[m].var[c]) |
Access the variance
Referenced by main().
#define MGAU_VAR 2 |
Referenced by mgau_dump(), and mgau_init().
#define mgau_veclen | ( | g | ) | ((g)->veclen) |
Access an integer array contains the size of each stream
Referenced by main(), mgau_comp_eval(), mgau_dump(), mgau_eval(), and mgau_var_nzvec_floor().
#define MIX_INT_FLOAT_COMP 20003 |
Referenced by main(), mgau_eval(), and mgau_init().
#define NO_BSTIDX -1 |
Referenced by approx_cont_mgau_frame_eval(), and mgau_eval().
#define NOT_UPDATED -100 |
#define SEMIHMM 10002 |
Referenced by mgau_init().
S3DECODER_EXPORT int32 mgau_comp_eval | ( | mgau_model_t * | g, | |
int32 | s, | |||
float32 * | x, | |||
int32 * | score | |||
) |
Like mgau_eval(), but return the scores of the individual components, instead of combining them into a senone score.
g | In: Set of mixture Gaussians | |
s | In: Mixture being considered | |
x | In: Input vector being compared to the components | |
score | Out: Array of scores for each component |
References mgau_model_t::distfloor, mgau_model_t::logmath, mgau_t::lrd, mgau_t::mean, mgau_model_t::mgau, mgau_veclen, mgau_t::n_comp, and mgau_t::var.
int32 mgau_dump | ( | mgau_model_t * | g, | |
int32 | type | |||
) |
A routine that dump all mean and variance parameters of a set of gaussian distribution.
g | In: Set of mixture Gaussians | |
type | In: type of output, MGAU_MEAN for mean or MGAU_VAR for variance. |
References mgau_t::mean, mgau_model_t::mgau, MGAU_MEAN, mgau_n_comp, mgau_n_mgau, MGAU_VAR, mgau_veclen, and mgau_t::var.
S3DECODER_EXPORT int32 mgau_eval | ( | mgau_model_t * | g, | |
int32 | m, | |||
int32 * | active, | |||
float32 * | x, | |||
int32 | fr, | |||
int32 | update_best_id | |||
) |
Evaluate a single mixture Gaussian at the given vector x; i.e., compute the Mahalanobis distance of x from each mean in the mixture, and combine them using the mixture weights. Return value: The final score from this evaluation (a logs3 domain value). NOTE: if the specified mixture is empty, S3_LOGPROB_ZERO is returned (see libmisc/libmisc.h).
Compute the log likelihood of a Gaussian mixture model in fixed-point. Notice that within the program, the Gaussian distribution is computed using floating point. But log-add is done in fixed point (usually by table lookup).
g | In: The entire mixture Gaussian model | |
m | In: The chosen mixture in the model (i.e., g->mgau[m]) | |
active | In: An optional, -1 terminated list of active component indices; if non-NULL, only the specified components are used in the evaluation. | |
x | In: Input observation vector (of length g->veclen). | |
fr | In: Frame number where GMM m is updated | |
update_best_id | In: Whether the best index for the GMM will be updated or not |
References mgau_t::bstidx, mgau_t::bstscr, mgau_model_t::comp_type, mgau_model_t::distfloor, mgau_model_t::logmath, mgau_model_t::mgau, mgau_veclen, MIX_INT_FLOAT_COMP, NO_BSTIDX, S3_LOGPROB_ZERO, and mgau_t::updatetime.
Referenced by approx_cont_mgau_ci_eval(), and approx_cont_mgau_frame_eval().
S3DECODER_EXPORT void mgau_free | ( | mgau_model_t * | g | ) |
RAH Free memory allocated by mgau_init
ARCHAN, I noticed this program because of Ricky's comment. In 2004, a very useful tool called valgrind started to be available for Linux. This tool allows me to pick up a lot of memory problems easily.
g | In: A set of model to free |
References mgau_t::fullvar, mgau_t::lrd, mgau_t::mean, mgau_model_t::mgau, mgau_t::mixw, mgau_t::mixw_f, and mgau_t::var.
Referenced by main().
S3DECODER_EXPORT mgau_model_t* mgau_init | ( | const char * | meanfile, | |
const char * | varfile, | |||
float64 | varfloor, | |||
const char * | mixwfile, | |||
float64 | mixwfloor, | |||
int32 | precomp, | |||
const char * | senmgau, | |||
int32 | comp_type, | |||
logmath_t * | logmath | |||
) |
Create a new mixture Gaussian model from the given files (Sphinx3 format). Optionally, apply the precomputations mentioned in the main comment above.
At the moment, S3 models have the same # of means in each codebook and 1 var/mean
meanfile | In: File containing means of mixture gaussians | |
varfile | In: File containing variances of mixture gaussians | |
varfloor | In: Floor value applied to variances; e.g., 0.0001 | |
mixwfile | In: File containing mixture weights | |
mixwfloor | In: Floor value for mixture weights; e.g., 0.0000001 | |
precomp | In: If TRUE, create and precompute mgau_t.lrd and also transform each var value to 1/(2*var). (If FALSE, one cannot use the evaluation routines provided here.) | |
senmgau | In: type of the gaussians distribution, .cont. or .semi. FIX me! This is confusing! | |
comp_type | In: Type of computation in this set of gaussian mixtures. |
References mgau_model_t::comp_type, CONTHMM, mgau_model_t::distfloor, FULL_FLOAT_COMP, FULL_INT_COMP, mgau_model_t::gau_type, mgau_model_t::logmath, mgau_model_t::mgau, MGAU_MEAN, MGAU_VAR, MIX_INT_FLOAT_COMP, S3_LOGPROB_ZERO, S3_LOGPROB_ZERO_F, SEMIHMM, mgau_t::var, and mgau_model_t::verbose.
Referenced by main().
S3DECODER_EXPORT int32 mgau_mean_reload | ( | mgau_model_t * | g, | |
const char * | mean_file_name | |||
) |
Reloading the means. This is particularly useful for speaker adaptation.
reload the mean file
g | In/Out: The GMM | |
mean_file_name | In: file name for the mean file. |
References mgau_model_t::mgau, and MGAU_MEAN.
int32 mgau_var_nzvec_floor | ( | mgau_model_t * | g, | |
float64 | floor | |||
) |
Floor any variance vector that is non-zero (vector).
g | In: A mixture of Gaussian components | |
floor | In: The floor value |
References mgau_model_t::mgau, mgau_n_comp, mgau_n_mgau, mgau_veclen, mgau_t::var, vector_is_zero(), and mgau_model_t::verbose.