Classes | Functions
subvq.h File Reference

Implementation of Sub-vector quantization. More...

#include <cmd_ln.h>
#include <logmath.h>
#include "s3types.h"
#include "cont_mgau.h"
#include "vector.h"

Go to the source code of this file.

Classes

struct  subvq_t
 Wrapper structures of sub-vector quantization. More...

Functions

subvq_tsubvq_init (const char *file, float64 varfloor, int32 max_sv, mgau_model_t *g, cmd_ln_t *config, logmath_t *logmath)
void subvq_free (subvq_t *vq)
int32 subvq_frame_eval (subvq_t *vq, mgau_model_t *g, int32 beam, float32 *feat, int32 *sen_active, int32 *senscr)
void subvq_gautbl_eval_logs3 (subvq_t *vq, float32 *feat, logmath_t *logmath)
void subvq_subvec_eval_logs3 (subvq_t *vq, float32 *feat, int32 sv, logmath_t *logmath)
int32 subvq_mgau_shortlist (subvq_t *vq, int32 m, int32 n, int32 beam)
int32 subvq_mgau_eval (mgau_model_t *g, subvq_t *vq, int32 m, int32 n, int32 *active)

Detailed Description

Implementation of Sub-vector quantization.

Function Documentation

int32 subvq_frame_eval ( subvq_t vq,
mgau_model_t g,
int32  beam,
float32 *  feat,
int32 *  sen_active,
int32 *  senscr 
)

Evaluate senone scores for one frame. If subvq model is available, for each senone, first get approximate Gaussian density scores using it; obtain a shortlist of Gaussians using these scores, then evaluate the shortlist exactly. If no subvq model, evaluate senones using all Gaussian densities. Finally, scale senone scores by subtracting the best.

Returns
The normalization factor (best senone absolute score).
Parameters
vqIn: A sub-vector model
gIn: Exact mixture Gaussian model
beamIn: (Logs3) threshold for selecting shortlist; range = [-infinity(widest beam), 0(narrowest)]
featIn: Input feature vector for this frame
sen_activeIn: Active flags for each senone (optional). If not NULL, only active ones evaluated
senscrOut: Normalized senone scores
void subvq_free ( subvq_t vq)

Deallocate sub-vector quantization

Parameters
vqIn: A sub-vector model
void subvq_gautbl_eval_logs3 ( subvq_t vq,
float32 *  feat,
logmath_t *  logmath 
)

Evaluate the Mahalanobis distances between the given feature vector and each entry in the given subvq codebook. Save results, as logs3 values, in vq->vqdist[][].

Parameters
vqIn/Out: Reference subvq structure
featIn: Subvectors extracted from this, and compared to relevant subvq codewords

Referenced by approx_cont_mgau_ci_eval(), and approx_cont_mgau_frame_eval().

subvq_t* subvq_init ( const char *  file,
float64  varfloor,
int32  max_sv,
mgau_model_t g,
cmd_ln_t *  config,
logmath_t *  logmath 
)

SubVQ file format: VQParam #Original-Codebooks #Original-Codewords/codebook(max) -> #Subvectors #VQ-codewords Subvector 0 length <length> <feature-dim> <feature-dim> <feature-dim> ... Subvector 1 length <length> <feature-dim> <feature-dim> <feature-dim> ... ... Codebook 0 Row 0 of mean/var values (interleaved) for subvector 0 codebook (in 1 line) Row 1 of above Row 2 of above ... Map 0 Mappings for state 0 codewords (in original model) to codewords of this subvector codebook Mappings for state 1 codewords (in original model) to codewords of this subvector codebook Mappings for state 2 codewords (in original model) to codewords of this subvector codebook ... Repeated for each subvector codebook 1 Repeated for each subvector codebook 2 ... End

Returns
initialized sub-vq
Parameters
fileIn: Subvector model file
varfloorIn: Floor to be applied to variance values
max_svIn: Use the first so many subvectors instead of all; if <0, use all
gIn: Original model from which this subvq model was built, for cross-validation; optional
int32 subvq_mgau_eval ( mgau_model_t g,
subvq_t vq,
int32  m,
int32  n,
int32 *  active 
)

Compute the scores of a gaussian using only sum of the sub-vector scores.

Returns
best senone score.
Parameters
gIn: Gaussian
vqIn: the SVQ
mIn: GMM Index
nIn :#Components in a specified mixture
activeIn:Active list of mixture
int32 subvq_mgau_shortlist ( subvq_t vq,
int32  m,
int32  n,
int32  beam 
)
Parameters
vqIn subvq
mIn: GMM index
nIn: #Components in specified mixture
beamIn: Threshold to select active components
void subvq_subvec_eval_logs3 ( subvq_t vq,
float32 *  feat,
int32  sv,
logmath_t *  logmath 
)

Evaluate the codewords for a single given subvector sv, wrt the input feature vector. Save results, as logs3 values, in vq->vqdist[sv][]. (Basically, like subvq_gautbl_eval_logs3, but for a single given subvector instead of all.)

Parameters
vqIn/Out: Reference subvq structure
featIn: Input feature subvector extracted from this, and compared to relevant codewords
svIn: ID of subvector being evaluated