/* LoadMgeTrnHmmFile: */ static void LoadMgeTrnHmmFile(int nIter) { char hext[15], hmmFile[255]; ResetHeap(&hmmStack); CreateHeap(&hmmStack, "Model Stack", MSTAK, 1, 1.0, 80000, 400000); sprintf(hext, "mmf%d", nIter); MakeFN(mmfFn, outDir, hext, hmmFile); CreateHMMSet(&hset, &hmmStack, TRUE); AddMMF(&hset, hmmFile); if (trace & T_TOP) printf("Loading MGE-trained HMM in iteration %d ... ... \n", nIter); if (MakeHMMSet(&hset, hmmListFn) < SUCCESS) HError(2321, "Initialise: MakeHMMSet failed"); if (LoadHMMSet(&hset, hmmDir, hmmExt) < SUCCESS) HError(2321, "Initialise: LoadHMMSet failed"); SetParmHMMSet(&hset); /* variance inversion, MGE training only support INVDIAGC case */ ConvDiagC(&hset, TRUE); if (funcType == MGE_TRAIN) AttachAccToModel(); }
/* Initialise: load hmm and initialise global data structures */ void Initialise(void) { LabId hmmId; char base[MAXSTRLEN]; char path[MAXSTRLEN]; char ext[MAXSTRLEN]; int s; /* Stacks for global structures requiring memory allocation */ CreateHeap(&segmentStack,"SegStore", MSTAK, 1, 0.0, 100000, LONG_MAX); CreateHeap(&sequenceStack,"SeqStore", MSTAK, 1, 0.0, 10000, 10000); CreateHeap(&clustSetStack,"ClustSetStore", MSTAK, 1, 0.0, 1000, 1000); CreateHeap(&transStack,"TransStore", MSTAK, 1, 0.0, 1000, 1000); CreateHeap(&traceBackStack,"TraceBackStore", MSTAK, 1, 0.0, 1000, 1000); CreateHeap(&bufferStack,"BufferStore", MSTAK, 1, 0.0, 1000, 1000); CreateHeap(&msdinfoStack,"MSDInfoStore", MSTAK, 1, 0.0, 1000, 1000); /* Load HMM def */ if(MakeOneHMM( &hset, BaseOf(hmmfn,base))<SUCCESS) HError(2128,"Initialise: MakeOneHMM failed"); if(LoadHMMSet( &hset,PathOf(hmmfn,path),ExtnOf(hmmfn,ext))<SUCCESS) HError(2128,"Initialise: LoadHMMSet failed"); SetParmHMMSet(&hset); if ((hset.hsKind==DISCRETEHS)||(hset.hsKind==TIEDHS)) uFlags = (UPDSet) (uFlags & (~(UPMEANS|UPVARS))); AttachAccs(&hset, &gstack, uFlags); /* Get a pointer to the physical HMM and set related globals */ hmmId = GetLabId(base,FALSE); macroLink = FindMacroName(&hset,'h',hmmId); hmmLink = (HLink)macroLink->structure; nStates = hmmLink->numStates; nStreams = hset.swidth[0]; for(s=1; s<=nStreams; s++) maxMixInS[s] = MaxMixInS(hmmLink, s); msdInfo = CreateMSDInfo(&msdinfoStack, hmmLink); SetVFloor( &hset, vFloor, minVar); if(segLab != NULL) segId = GetLabId(segLab,TRUE); if(trace>0) PrintInitialInfo(); thisP = CreateVector(&gstack,nStates); lastP = CreateVector(&gstack,nStates); }
/* Initialise: */ static void Initialise() { char macroname[MAXSTRLEN]; AdaptXForm *xform; /* load HMMs and init HMMSet related global variables */ if (trace & T_TOP) printf("Loading HMM for updating ... ... \n"); if (MakeHMMSet(&hset, hmmListFn) < SUCCESS) HError(2321, "Initialise: MakeHMMSet failed"); if (LoadHMMSet(&hset, hmmDir, hmmExt) < SUCCESS) HError(2321, "Initialise: LoadHMMSet failed"); SetParmHMMSet(&hset); /* variance inversion, MGE training only support INVDIAGC case */ if (hset.ckind == DIAGC) ConvDiagC(&hset, TRUE); /* load transform */ if (xformfn != NULL) { xform = LoadOneXForm(&hset, NameOf(xformfn, macroname), xformfn); SetXForm(&hset, &xfInfo, xform); } if (funcType == MGE_TRAIN) AttachAccToModel(); /* reload the HMM for reference in training */ if (mtInfo->bOrigHmmRef) { if (trace & T_TOP) printf("Loading HMM for reference ... ... \n"); if (MakeHMMSet(&orighset, hmmListFn) < SUCCESS) HError(2321, "Initialise: MakeHMMSet failed"); if (LoadHMMSet(&orighset, hmmDir, hmmExt) < SUCCESS) HError(2321, "Initialise: LoadHMMSet failed"); SetParmHMMSet(&orighset); /* variance inversion, MGE training only support INVDIAGC case */ if (hset.ckind == DIAGC) ConvDiagC(&orighset, TRUE); /* load transform */ if (xformfn != NULL) { xform = LoadOneXForm(&orighset, NameOf(xformfn, macroname), xformfn); SetXForm(&orighset, &xfInfo, xform); } } if (trace & T_TOP) { printf("System is "); switch (hset.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", hset.numLogHMM, hset.numPhyHMM, hset.vecSize); 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); } /* initialize a MgeTrnInfo for MGE training of HMM */ InitMgeTrnInfo(); }
/* Initialise: load HMMs and create accumulators */ static void Initialise(void) { int s,V; Boolean eSep; char base[MAXSTRLEN]; char path[MAXSTRLEN]; char ext[MAXSTRLEN]; /* Load HMM defs */ if(MakeOneHMM(&hset,BaseOf(hmmfn,base))<SUCCESS) HError(2028,"Initialise: MakeOneHMM failed"); if(LoadHMMSet(&hset,PathOf(hmmfn,path),ExtnOf(hmmfn,ext))<SUCCESS) HError(2028,"Initialise: LoadHMMSet failed"); SetParmHMMSet(&hset); if (hset.hsKind==DISCRETEHS || hset.hsKind==TIEDHS) HError(2030,"Initialise: HCompV only uses continuous models"); /* Create a heap to store the input data */ /*CreateHeap(&iStack,"InBuf", MSTAK, 1, 0.5, 100000, LONG_MAX);*/ /* Get a pointer to the physical HMM */ hmmId = GetLabId(base,FALSE); macroLink = FindMacroName(&hset,'h',hmmId); if (macroLink==NULL) HError(2020,"Initialise: cannot find hmm %s in hset",hmmfn); hmmLink = (HLink)macroLink->structure; /* Find out for which streams full covariance is needed */ CheckVarianceKind( ); /* Create accumulators for the mean and variance */ for (s=1;s<=hset.swidth[0]; s++){ V = hset.swidth[s]; accs[s].meanSum=CreateVector(&gstack,V); ZeroVector(accs[s].meanSum); if (fullcNeeded[s]) { accs[s].squareSum.inv=CreateSTriMat(&gstack,V); accs[s].fixed.inv=CreateSTriMat(&gstack,V); ZeroTriMat(accs[s].squareSum.inv); } else { accs[s].squareSum.var=CreateSVector(&gstack,V); accs[s].fixed.var=CreateSVector(&gstack,V); ZeroVector(accs[s].squareSum.var); } } /* Create an object to hold the input parameters */ SetStreamWidths(hset.pkind,hset.vecSize,hset.swidth,&eSep); obs=MakeObservation(&gstack,hset.swidth,hset.pkind,FALSE,eSep); if(segLab != NULL) { segId = GetLabId(segLab,TRUE); } if (trace&T_TOP) { printf("Calculating Fixed Variance\n"); printf(" HMM Prototype: %s\n",hmmfn); printf(" Segment Label: %s\n",(segLab==NULL)?"None":segLab); printf(" Num Streams : %d\n",hset.swidth[0]); printf(" UpdatingMeans: %s\n",(meanUpdate)?"Yes":"No"); printf(" Target Direct: %s\n",(outDir==NULL)?"Current":outDir); } }