Exemplo n.º 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) ) {
Exemplo n.º 2
0
/* UpdateModels: update all models and save them in newDir if set,
   new files have newExt if set */
void UpdateModels(void)
{
   int n;
   HLink hmm;
   HMMScanState hss;
   
   if (trace&T_INT){
      printf("Starting Model Update\n"); fflush(stdout);
   }

   if (hsKind==TIEDHS){
      if (uFlags & UPVARS)  /* TIEDHS therefore only done once per HMMSet */
         UpdateTMVars();
      if (uFlags & UPMEANS) 
         UpdateTMMeans();      
      if (uFlags & (UPMEANS|UPVARS))
         FixAllGConsts(&hset);
   }

   NewHMMScan(&hset,&hss);
   do {
      hmm = hss.hmm;   
      n = (int)hmm->hook;
      if (n<minEgs && !(trace&T_OPT))
         HError(-2428,"%s copied: only %d egs\n",HMMPhysName(&hset,hmm),n);
      if (n>=minEgs) {
         if (uFlags & UPTRANS)
            UpdateTrans(hmm);
         if (maxMixes>1 && uFlags & UPMIXES)
            UpdateWeights(hmm);
      }
      if (trace&T_OPT) {
         if (n<minEgs)
            printf("Model %s copied: only %d examples\n",
                   HMMPhysName(&hset,hmm),n);
         else
            printf("Model %s updated with %d examples\n",
                   HMMPhysName(&hset,hmm),n);
         fflush(stdout);
      }
   } while (GoNextHMM(&hss));
   EndHMMScan(&hss);
   if (trace&T_TOP){
      printf("Saving hmm's to dir %s\n",(newDir==NULL)?"Current":newDir); 
      fflush(stdout);
   }

   if(SaveHMMSet(&hset,newDir,newExt,NULL,saveBinary)<SUCCESS)
      HError(2411,"UpdateModels: SaveHMMSet failed");
   ResetHeaps();                               /* Clean Up */
   if (trace&T_TOP)
      printf("Reestimation complete - average log prob per frame = %e\n",
             totalPr/(double)totalT);
}