cont_mgau.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
00002 /* ====================================================================
00003  * Copyright (c) 1999-2004 Carnegie Mellon University.  All rights
00004  * reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer. 
00012  *
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in
00015  *    the documentation and/or other materials provided with the
00016  *    distribution.
00017  *
00018  * This work was supported in part by funding from the Defense Advanced 
00019  * Research Projects Agency and the National Science Foundation of the 
00020  * United States of America, and the CMU Sphinx Speech Consortium.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
00023  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
00024  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00025  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
00026  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00027  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00028  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00029  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
00030  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00031  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00032  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  * ====================================================================
00035  *
00036  */
00037 /*
00038  * cont_mgau.h -- Mixture Gaussians for continuous HMM models.
00039  *
00040  * **********************************************
00041  * CMU ARPA Speech Project
00042  *
00043  * Copyright (c) 1997 Carnegie Mellon University.
00044  * ALL RIGHTS RESERVED.
00045  * **********************************************
00046  *
00047  * HISTORY
00048  * $Log$
00049  * Revision 1.1  2006/04/05  20:27:30  dhdfu
00050  * A Great Reorganzation of header files and executables
00051  * 
00052  * Revision 1.15  2006/02/22 16:32:40  arthchan2003
00053  * Merged from SPHINX3_5_2_RCI_IRII_BRANCH: 1, Dave's change in 1.18 for removing temp_hack is followed 2, The logic of uninit_compact is changed, by default the code will remove a Gaussian if it has zero mean AND zero variance. The old behavior (removal if Gaussian has zero mean.) could be retained if specifying -remove_zero_var_gau=1, 3, Fix issue in  .
00054  *
00055  *
00056  * Revision 1.13.4.3  2005/07/05 21:28:57  arthchan2003
00057  * 1, Merged from HEAD. 2, Remove redundant keyword in cont_mgau.
00058  *
00059  * Revision 1.13.4.2  2005/07/05 06:48:54  arthchan2003
00060  * Merged from HEAD.
00061  *
00062  * Revision 1.14  2005/07/04 20:57:53  dhdfu
00063  * Finally remove the "temporary hack" for the endpointer, and do
00064  * everything in logs3 domain.  Should make it faster and less likely to
00065  * crash on Alphas.
00066  *
00067  * Actually it kind of duplicates the existing GMM computation functions,
00068  * but it is slightly different (see the comment in classify.c).  I don't
00069  * know the rationale for this.
00070  *
00071  * Revision 1.13.4.1  2005/07/05 05:47:59  arthchan2003
00072  * Fixed dox-doc. struct level of documentation are included.
00073  *
00074  *
00075  * Revision 1.13  2005/06/21 18:06:45  arthchan2003
00076  *
00077  * Log. 1, Fixed Doxygen documentation. 2, Added $Log$
00078  * Revision 1.1  2006/04/05  20:27:30  dhdfu
00079  * A Great Reorganzation of header files and executables
00080  * 
00081  * Log. 1, Fixed Doxygen documentation. 2, Added Revision 1.15  2006/02/22 16:32:40  arthchan2003
00082  * Log. 1, Fixed Doxygen documentation. 2, Added Merged from SPHINX3_5_2_RCI_IRII_BRANCH: 1, Dave's change in 1.18 for removing temp_hack is followed 2, The logic of uninit_compact is changed, by default the code will remove a Gaussian if it has zero mean AND zero variance. The old behavior (removal if Gaussian has zero mean.) could be retained if specifying -remove_zero_var_gau=1, 3, Fix issue in  .
00083  * Log. 1, Fixed Doxygen documentation. 2, Added
00084  *
00085  * Revision 1.4  2005/06/13 04:02:55  archan
00086  * Fixed most doxygen-style documentation under libs3decoder.
00087  *
00088  * Revision 1.3  2005/03/30 01:22:46  archan
00089  * Fixed mistakes in last updates. Add
00090  *
00091  * 
00092  * 20.Apr.2001  RAH (rhoughton@mediasite.com, ricky.houghton@cs.cmu.edu)
00093  *              Added mgau_free to free memory allocated by mgau_init()
00094  * 15-Dec-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
00095  *              Added mgau_model_t.{frm_sen_eval,frm_gau_eval}.
00096  *              Added mgau_var_nzvec_floor().
00097 
00098  * 
00099  * 28-Mar-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University.
00100  *              Started.
00101  */
00102 
00103 
00104 #ifndef _S3_CONT_MGAU_H_
00105 #define _S3_CONT_MGAU_H_
00106 
00107 #include <s3types.h>
00108 #include <logmath.h>
00109 
00113 #ifdef __cplusplus
00114 extern "C" {
00115 #endif
00116 #if 0
00117 } /* Fool Emacs into not indenting things. */
00118 #endif
00119 
00124 #define CONTHMM  10001 
00125 #define SEMIHMM  10002 
00127 #define FULL_INT_COMP 20001  
00128 #define FULL_FLOAT_COMP 20002 
00129 #define MIX_INT_FLOAT_COMP 20003 
00131 #define MGAU_MEAN               1 
00132 #define MGAU_VAR                2 
00133 #define MGAU_FULLVAR            3 
00135 #define NO_BSTIDX               -1 
00136 #define NOT_UPDATED              -100 
00157 /* 20040826 ARCHAN: 
00158  * Introduced hook to the GMM definition to allow gaussian computation using full float 
00159  * operations. Also added another hook that allows potential use of full covariance matrix. 
00160  * At this point, full covariance matrix computation was not fully implemented. 
00161  * If comp_type = MIX_INT_FLOAT_COMP, then the interger pointer will be used to store the 
00162  * mixture weight.  It is also important to initialize the logs3 routine separately.
00163  * If comp_type = FULL_FLOAT_COMP, then the floating point pointer will be used to store the mixture
00164  * weights. 
00165  */
00166 
00171 typedef struct {
00172     int32 n_comp;       
00175     int32 bstidx;         
00176     int32 bstscr;         
00177     int32 updatetime;     
00179     /* Definition for mean */
00180     float32 **mean;     
00182     /* Definition for variances */
00183     float32 **var;      
00186     float32 ***fullvar;   /* The n_comp (full) variances of the Gaussians. */
00187     /* A full co-variance matrix for a single mixture-Gaussian model for one senone */
00188     /* Dimension: n_comp * dimension * dimension */
00189 
00190     /* Definition for the log reciprocal terms */
00191     float32 *lrd;               
00194     /* Definitions for the mixture weights */
00195     int32 *mixw;                
00197     float32 *mixw_f;      
00199 } mgau_t;
00200 
00201 
00202 
00207 typedef struct {
00208     int32 n_mgau;       
00209     int32 max_comp;     
00210     int32 veclen;       
00211     mgau_t *mgau;       
00212     float64 distfloor;  
00214     int32 comp_type;  
00215     int32 verbose;    
00217     /* Used only in the flat lexicon decoder, statistics */
00218     int32 frm_sen_eval;         
00219     int32 frm_gau_eval;         
00220     int32 frm_ci_sen_eval;        
00221     int32 frm_ci_gau_eval;        
00223     int32 gau_type; 
00226     logmath_t *logmath;         
00227 } mgau_model_t;
00228 
00229 
00257 #define mgau_n_mgau(g)          ((g)->n_mgau)
00258 #define mgau_max_comp(g)        ((g)->max_comp)
00259 #define mgau_veclen(g)          ((g)->veclen)
00260 #define mgau_n_comp(g,m)        ((g)->mgau[m].n_comp)
00261 #define mgau_mean(g,m,c)        ((g)->mgau[m].mean[c])
00262 #define mgau_var(g,m,c)         ((g)->mgau[m].var[c])
00263 #define mgau_fullvar(g,m,c)     ((g)->mgau[m].fullvar[c])
00264 #define mgau_mixw(g,m,c)        ((g)->mgau[m].mixw[c])
00265 #define mgau_mixw_f(g,m,c)      ((g)->mgau[m].mixw_f[c])
00266 #define mgau_lrd(g,m,c)         ((g)->mgau[m].lrd[c])
00267 #define mgau_lrdi(g,m,c)        ((g)->mgau[m].lrdi[c])
00268 #define mgau_frm_sen_eval(g)    ((g)->frm_sen_eval)
00269 #define mgau_frm_gau_eval(g)    ((g)->frm_gau_eval)
00270 #define mgau_frm_cisen_eval(g)  ((g)->frm_ci_sen_eval)
00271 #define mgau_frm_cigau_eval(g)  ((g)->frm_ci_gau_eval)
00272 
00283 S3DECODER_EXPORT
00284 mgau_model_t *
00285 mgau_init (const char *meanfile,        
00286            const char *varfile,         
00287            float64 varfloor,            
00288            const char *mixwfile,        
00289            float64 mixwfloor,           
00290            int32 precomp,               
00293            const char* senmgau,         
00295            int32 comp_type,             
00296            logmath_t *logmath);
00297                                 
00298 
00303 int32 mgau_var_nzvec_floor (mgau_model_t *g,  
00304                             float64 floor 
00305     );
00306 
00307 
00315 /* The hybrid integer and floating point implementation of GMM computation */
00316 
00317 S3DECODER_EXPORT
00318 int32 mgau_eval (mgau_model_t *g,       
00319            int32 m,             
00320            int32 *active_comp,  
00323            float32 *x, 
00324            int32 fr,    
00325            int32 bUpdBstIdx    
00326     );          
00327 
00333 S3DECODER_EXPORT
00334 int32 mgau_comp_eval (mgau_model_t *g,  
00335                       int32 s,          
00336                       float32 *x,       
00337                       int32 *score      
00338     );
00339 
00345 int32 mgau_dump (mgau_model_t *g,  
00346                  int32 type      
00349     );
00350 
00354 S3DECODER_EXPORT
00355 void mgau_free (mgau_model_t *g 
00356     );
00357 
00358 
00362 S3DECODER_EXPORT
00363 int32 mgau_mean_reload(mgau_model_t *g,  
00364                        const char* mean_file_name 
00365     );
00366 
00367 #if 0
00368 { /* Stop indent from complaining */
00369 #endif
00370 #ifdef __cplusplus
00371 }
00372 #endif
00373 
00374 
00375 #endif

Generated on 7 Mar 2010 by  doxygen 1.6.1