Пример #1
0
         HError(999,"Can only update linear transforms OR model parameters!");

      xfInfo.useOutXForm = TRUE;

      /* This initialises things - temporary hack - THINK!! */

      CreateAdaptXForm(hset, "tmp");

   } 



   

   /* initialise and  pass information to the forward backward library */

   InitialiseForBack(fbInfo, x, hset, uFlags, pruneInit, pruneInc,

                     pruneLim, minFrwdP);



   if (parMode != 0) {

      ConvLogWt(hset);

   }

   /* 2-model reestimation */

   if (al_hmmUsed){

       if (trace&T_TOP)

           printf("2-model re-estimation enabled\n");

       /* load alignment HMM set */

       CreateHMMSet(&al_hset,&hmmStack,TRUE);

       xfInfo.al_hset = &al_hset;

       if (xfInfo.alXFormExt == NULL) xfInfo.alXFormExt = xfInfo.inXFormExt;

       /* load multiple MMFs */

       if (strlen(al_hmmMMF) > 0 ) {

           char *p,*q;

           Boolean eos;

           p=q=al_hmmMMF;

           for(;;) {

               eos = (*p=='\0');

               if ( ( isspace((int) *p) || *p == '\0' ) && (q!=p) ) {
Пример #2
0
/* EXPORT->MAPUpdateModels: update all models and save them in newDir if set,
   new files have newExt if set */
void MAPUpdateModels(HMMSet *hset, UPDSet uFlags)
{
  HMMScanState hss;
  HLink hmm;
  int px,nmapped=0,totM;
  long n;

  if (hset->logWt == TRUE) HError(999,"HMap: requires linear weights");

  /* Intialise a few global variables */
  SetVFloor( hset, vFloor, minVar);
  maxM = MaxMixInSet(hset);
  totM = TotMixInSet(hset);
  S = hset->swidth[0];

  if (hset->hsKind == TIEDHS){ /* TIEDHS - update mu & var once per HMMSet */
    HError(999,"TIEDHS kind not currently supported in MAP estimation");
  }

  NewHMMScan(hset,&hss);
  px=1;
  do {   
    hmm = hss.hmm;
    n = (long)hmm->hook;
    if (n<minEgs && !(trace&T_UPD))
      HError(-2331,"UpdateModels: %s[%d] copied: only %d egs\n",
	     HMMPhysName(hset,hmm),px,n);
    if (n>=minEgs && n>0) {
      if (uFlags & UPTRANS)
	HError(999,"No support for MAP updating transition probabilities");
      if (maxM>1 && uFlags & UPMIXES)
	UpdateWeights(hset,px,hmm);
      if (hset->hsKind != TIEDHS){
	if (uFlags & UPVARS)
	  UpdateVars(hset,px,hmm);
	if (uFlags & UPMEANS)
	  nmapped += UpdateMeans(hset,px,hmm);
	if (uFlags & (UPMEANS|UPVARS))
	  FixGConsts(hmm);
      }  
    }
    px++;
  } while (GoNextHMM(&hss));
  EndHMMScan(&hss);
  if (trace&T_TOP) {
    printf("Observed components (means) %d of %d: %.2f\n",nmapped,totM,100*(float)nmapped/(float)totM);
    if (nFloorVar > 0)
      printf("Total %d floored variance elements in %d different mixes\n",
	     nFloorVar,nFloorVarMix);
    fflush(stdout);
  }
   
  /* Reset vfloor */
  ResetVFloor(hset,vFloor);
}