public override void initializeModels(string context) { this.dumpMemoryInfo("TrainManager start"); Iterator iterator = this.acousticModels.iterator(); while (iterator.hasNext()) { TrainerAcousticModel trainerAcousticModel = (TrainerAcousticModel)iterator.next(); this.controlFile.startUtteranceIterator(); while (this.controlFile.hasMoreUtterances()) { Utterance utterance = this.controlFile.nextUtterance(); this.initLearner.setUtterance(utterance); TrainerScore[] score; while ((score = this.initLearner.getScore()) != null) { if (!SimpleTrainManager.assertionsDisabled && score.Length != 1) { throw new AssertionError(); } trainerAcousticModel.accumulate(0, score); } } trainerAcousticModel.normalize(); } this.dumpMemoryInfo("acoustic model"); }
private void loadModels(string text) { this.dumpMemoryInfo("TrainManager start"); Iterator iterator = this.acousticModels.iterator(); while (iterator.hasNext()) { TrainerAcousticModel trainerAcousticModel = (TrainerAcousticModel)iterator.next(); trainerAcousticModel.load(); } this.dumpMemoryInfo("acoustic model"); }
public override void saveModels(string context) { if (1 == this.acousticModels.size()) { ((TrainerAcousticModel)this.acousticModels.get(0)).save(null); } else { Iterator iterator = this.acousticModels.iterator(); while (iterator.hasNext()) { AcousticModel acousticModel = (AcousticModel)iterator.next(); if (acousticModel is TrainerAcousticModel) { TrainerAcousticModel trainerAcousticModel = (TrainerAcousticModel)acousticModel; trainerAcousticModel.save(acousticModel.getName()); } } } }
public override void trainContextIndependentModels(string context) { if (this.learner == null) { this.loadModels(context); } this.dumpMemoryInfo("TrainManager start"); Iterator iterator = this.acousticModels.iterator(); while (iterator.hasNext()) { TrainerAcousticModel trainerAcousticModel = (TrainerAcousticModel)iterator.next(); float num = float.MaxValue; float num2 = 100f; int num3 = 0; while (num3 < this.maxIteration && num2 > this.minimumImprovement) { [email protected](new StringBuilder().append("Iteration: ").append(num3).toString()); trainerAcousticModel.resetBuffers(); this.controlFile.startUtteranceIterator(); while (this.controlFile.hasMoreUtterances()) { Utterance utterance = this.controlFile.nextUtterance(); UtteranceHMMGraph graph = new UtteranceHMMGraph(context, utterance, trainerAcousticModel, this.unitManager); this.learner.setUtterance(utterance); this.learner.setGraph(graph); TrainerScore[] nextTrainerScore = null; TrainerScore[] score; while ((score = this.learner.getScore()) != null) { for (int i = 0; i < score.Length; i++) { if (i > 0) { trainerAcousticModel.accumulate(i, score, nextTrainerScore); } else { trainerAcousticModel.accumulate(i, score); } } nextTrainerScore = score; } trainerAcousticModel.updateLogLikelihood(); } float num4 = trainerAcousticModel.normalize(); [email protected](new StringBuilder().append("Loglikelihood: ").append(num4).toString()); this.saveModels(context); if (num3 > 0) { if (num != 0f) { num2 = (num4 - num) / num * 100f; } else if (num == num4) { num2 = 0f; } [email protected](new StringBuilder().append("Finished iteration: ").append(num3).append(" - Improvement: ").append(num2).toString()); } num = num4; num3++; } } }