if (uFlags&UPXFORM) printf("XForms "); if (uFlags&UPMIXES && maxM>1) printf("MixWeights "); printf("\n\n "); if (parMode>=0) printf("Parallel-Mode[%d] ",parMode); printf("System is "); switch (hsKind){ case PLAINHS: printf("PLAIN\n"); break; case SHAREDHS: printf("SHARED\n"); break; case TIEDHS: printf("TIED\n"); break; case DISCRETEHS: printf("DISCRETE\n"); break; } printf("%d Logical/%d Physical Models Loaded, VecSize=%d\n",L,P,vSize); if (hset->numFiles>0) printf("%d MMF input files\n",hset->numFiles); if (mmfFn != NULL) printf("Output to MMF file: %s\n",mmfFn); fflush(stdout); } SetVFloor( hset, vFloor, minVar); totalPr = 0.0; if (xfInfo.inSpkrPat == NULL) xfInfo.inSpkrPat = xfInfo.outSpkrPat; if (xfInfo.paSpkrPat == NULL) xfInfo.paSpkrPat = xfInfo.outSpkrPat; if (uFlags&UPXFORM) { if ((hsKind != PLAINHS) && (hsKind != SHAREDHS)) HError(999,"Can only estimated transforms with PLAINHS and SHAREDHS!");
/* EXPORT->ConvDiagC Convert Diagonal Covariance Kind Converts all the HMMs in hset to INVDIAGC from DIAGC or vice versa. If convData is TRUE then each variance element is replaced by its reciprocal - otherwise only the CovKind in each HMM is changed and no data conversions are performed. */ void ConvDiagC(HMMSet *hset, Boolean convData) { HMMScanState hss; SVector v; int k; if (hset->hsKind == DISCRETEHS || hset->hsKind == TIEDHS) return; NewHMMScan(hset, &hss); while (GoNextMix(&hss,FALSE)) { if (hss.mp->ckind == DIAGC || hss.mp->ckind == INVDIAGC){ hss.mp->ckind = (hss.mp->ckind == DIAGC)?INVDIAGC:DIAGC; if (convData){ v = hss.mp->cov.var; if (! IsSeenV(v)) { for (k=1; k<=hset->swidth[hss.s]; k++) { if (v[k] > MAXVAR) v[k] = MAXVAR; if (v[k] < MINVAR) v[k] = MINVAR; v[k] = 1/v[k]; } TouchV(v); } } } } EndHMMScan(&hss); ClearSeenFlags(hset,CLR_ALL); }
/* UpdateParameters: in hmm using counts in accumulators */ void UpdateParameters(void) { HMMScanState hss; int size; StreamInfo *sti; WtAcc *wa; MuAcc *ma = NULL; VaAcc *va; TrAcc *ta; Boolean hFound = FALSE,shared; NewHMMScan(&hset,&hss); do if (hmmLink == hss.hmm){ hFound = TRUE; while (GoNextState(&hss,TRUE)) { while (GoNextStream(&hss,TRUE)) { sti = hss.sti; if (hss.M>1 && (uFlags&UPMIXES)){ wa = (WtAcc *)sti->hook; if (hset.hsKind == DISCRETEHS) UpDProbs(hss.i,hss.s,hss.M,wa,sti->spdf.dpdf); else UpWeights(hss.i,hss.s,hss.M,wa,sti); } if (hss.isCont && (uFlags&(UPMEANS|UPVARS)))/*PLAINHS or SHAREDHS*/ while (GoNextMix(&hss,TRUE)) { size = VectorSize(hss.mp->mean); if (!IsSeenV(hss.mp->mean)) { ma = (MuAcc *)GetHook(hss.mp->mean); if (ma->occ!=0.0) UpMeans(hss.i,hss.s,hss.m,size,ma,hss.mp->mean); /* NB old mean left in ma->mu */ TouchV(hss.mp->mean); } if (!IsSeenV(hss.mp->cov.var)) { if (uFlags&UPVARS) { va = (VaAcc *)GetHook(hss.mp->cov.var); shared = (GetUse(hss.mp->cov.var) > 1) ? TRUE:FALSE; if (va->occ!=0.0) UpVars(hss.i,hss.s,hss.m,size,va,ma->mu,hss.mp->mean,shared,hss.mp); } TouchV(hss.mp->cov.var); } } } } if (!IsSeenV(hmmLink->transP)) { if (uFlags&UPTRANS){ ta = (TrAcc *)GetHook(hmmLink->transP); UpTrans(ta,hmmLink->transP); } TouchV(hmmLink->transP); } } while (!hFound && GoNextHMM(&hss)); EndHMMScan(&hss); if (!hFound) HError(2129,"UpdateParameters: hmm not found"); }
/* EXPORT->ConvExpWt Converts all mixture log-weights into weights. */ void ConvExpWt(HMMSet *hset) { HMMScanState hss; if (hset->hsKind == DISCRETEHS || hset->hsKind == TIEDHS) return; NewHMMScan(hset, &hss); while (GoNextMix(&hss,FALSE)) hss.me->weight = exp(hss.me->weight); EndHMMScan(&hss); }
static int TotMixInSet(HMMSet *hset) { HMMScanState hss; HLink hmm; int nmix=0; NewHMMScan(hset,&hss); do { hmm = hss.hmm; while (GoNextState(&hss,TRUE)) { while (GoNextStream(&hss,TRUE)) { if (hss.isCont) /* PLAINHS or SHAREDHS */ while (GoNextMix(&hss,TRUE)) { if (!IsSeenV(hss.mp->mean)) { nmix++; TouchV(hss.mp->mean); } } } } } while (GoNextHMM(&hss)); EndHMMScan(&hss); return(nmix); }