private static CRFTrainerByThreadedLabelLikelihood makeNewTrainer(CRF crf) { CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, getCpuCount()); trainer.setGaussianPriorVariance(2); trainer.setAddNoFactors(true); trainer.setUseSomeUnsupportedTrick(false); return trainer; }
public boolean trainIncremental (InstanceList training) { return train (training, Integer.MAX_VALUE); }
getOptimizableCRF(trainingSet); // This will set this.mcrf if necessary getOptimizer(trainingSet); // This will set this.opt if necessary iterationCount++; logger.info ("CRF finished one iteration of maximizer, i="+i); runEvaluators(); } catch (IllegalArgumentException e) { e.printStackTrace();
private TransducerTrainer trainOnce(Pipe pipe, InstanceList trainData) { Stopwatch watch = Stopwatch.createStarted(); CRF crf = new CRF(pipe, null); crf.addOrderNStates(trainData, new int[]{1}, null, null, null, null, false); crf.addStartState(); crf.setWeightsDimensionAsIn(trainData, false); if (initFrom != null) { crf.initializeApplicableParametersFrom(initFrom); } log.info("Starting alignTag training..."); CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8); trainer.setGaussianPriorVariance(2); trainer.setAddNoFactors(true); trainer.setUseSomeUnsupportedTrick(false); trainer.train(trainData); trainer.shutdown(); watch.stop(); log.info("Syll align Tag CRF Training took " + watch.toString()); crf.getInputAlphabet().stopGrowth(); crf.getOutputAlphabet().stopGrowth(); return trainer; }
CRFTrainerByThreadedLabelLikelihood crft = new CRFTrainerByThreadedLabelLikelihood (crf,numThreads.value); crft.setGaussianPriorVariance(var); crft.setUseSparseWeights(false); crft.setUseSomeUnsupportedTrick(false); crft.setUseSparseWeights(true); crft.setUseSomeUnsupportedTrick(true); crft.setUseSparseWeights(true); crft.setUseSomeUnsupportedTrick(false); boolean converged; for (int i = 1; i <= iterations; i++) { converged = crft.train (training, 1); if (i % 1 == 0 && eval != null) { // Change the 1 to higher integer to evaluate less often eval.evaluate(crft); crft.shutdown();
CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood( crf, threads); trainer.setGaussianPriorVariance(1); trainer.train(trainingSet);
this.lastTrainer = trainer; trainer.train(examples, opts.maxPronouncerTrainingIterations); trainer.shutdown(); // just closes the pool; next call to train will create a new one trainer.getCRF().pruneFeaturesBelowPercentile(opts.trimFeaturesUnderPercentile); trainer.train(examples); trainer.shutdown();
CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood( crf, threads); trainer.train(trainingInstanceList); LOG.info("done training CRF");
public Optimizer getOptimizer (InstanceList trainingSet) { getOptimizableCRF(trainingSet); if (optimizer == null || optimizable != optimizer.getOptimizable()) { optimizer = new LimitedMemoryBFGS(threadedOptimizable); } return optimizer; }
private TransducerTrainer trainOnce(Pipe pipe, InstanceList trainData) { Stopwatch watch = Stopwatch.createStarted(); CRF crf = new CRF(pipe, null); crf.addOrderNStates(trainData, new int[]{1}, null, null, null, null, false); crf.addStartState(); log.info("Starting alignTag training..."); CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8); trainer.setGaussianPriorVariance(2); // trainer.setUseSomeUnsupportedTrick(false); trainer.train(trainData); trainer.shutdown(); watch.stop(); log.info("Align Tag CRF Training took " + watch.toString()); crf.getInputAlphabet().stopGrowth(); crf.getOutputAlphabet().stopGrowth(); return trainer; }
CRFTrainerByThreadedLabelLikelihood crft = new CRFTrainerByThreadedLabelLikelihood (crf,numThreads.value); crft.setGaussianPriorVariance(var); crft.setUseSparseWeights(false); crft.setUseSomeUnsupportedTrick(false); crft.setUseSparseWeights(true); crft.setUseSomeUnsupportedTrick(true); crft.setUseSparseWeights(true); crft.setUseSomeUnsupportedTrick(false); boolean converged; for (int i = 1; i <= iterations; i++) { converged = crft.train (training, 1); if (i % 1 == 0 && eval != null) { // Change the 1 to higher integer to evaluate less often eval.evaluate(crft); crft.shutdown();
public Optimizer getOptimizer (InstanceList trainingSet) { getOptimizableCRF(trainingSet); if (optimizer == null || optimizable != optimizer.getOptimizable()) { optimizer = new LimitedMemoryBFGS(threadedOptimizable); } return optimizer; }
private TransducerTrainer trainOnce(Pipe pipe, InstanceList examples) { Stopwatch watch = Stopwatch.createStarted(); CRF crf = new CRF(pipe, null); crf.addOrderNStates(examples, new int[]{1}, null, null, null, null, false); crf.addStartState(); // crf.setWeightsDimensionAsIn(examples, false); log.info("Starting syllchain training..."); CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8); trainer.setGaussianPriorVariance(2); // trainer.setUseSomeUnsupportedTrick(false); // trainer.setAddNoFactors(true); trainer.train(examples); trainer.shutdown(); watch.stop(); log.info("SyllChain CRF Training took " + watch.toString()); crf.getInputAlphabet().stopGrowth(); crf.getOutputAlphabet().stopGrowth(); return trainer; }
CRFTrainerByThreadedLabelLikelihood crft = new CRFTrainerByThreadedLabelLikelihood (crf,numThreads.value); crft.setGaussianPriorVariance(var); crft.setUseSparseWeights(false); crft.setUseSomeUnsupportedTrick(false); crft.setUseSparseWeights(true); crft.setUseSomeUnsupportedTrick(true); crft.setUseSparseWeights(true); crft.setUseSomeUnsupportedTrick(false); boolean converged; for (int i = 1; i <= iterations; i++) { converged = crft.train (training, 1); if (i % 1 == 0 && eval != null) { // Change the 1 to higher integer to evaluate less often eval.evaluate(crft); crft.shutdown();
getOptimizableCRF(trainingSet); // This will set this.mcrf if necessary getOptimizer(trainingSet); // This will set this.opt if necessary iterationCount++; logger.info ("CRF finished one iteration of maximizer, i="+i); runEvaluators(); } catch (IllegalArgumentException e) { e.printStackTrace();
/** * Train a CRF on various-sized subsets of the data. This method is typically used to accelerate training by * quickly getting to reasonable parameters on only a subset of the parameters first, then on progressively more data. * @param training The training Instances. * @param numIterationsPerProportion Maximum number of Maximizer iterations per training proportion. * @param trainingProportions If non-null, train on increasingly * larger portions of the data, e.g. new double[] {0.2, 0.5, 1.0}. This can sometimes speedup convergence. * Be sure to end in 1.0 if you want to train on all the data in the end. * @return True if training has converged. */ public boolean train (InstanceList training, int numIterationsPerProportion, double[] trainingProportions) { return train(training, numIterationsPerProportion, numIterationsPerProportion, trainingProportions); }
public Optimizer getOptimizer (InstanceList trainingSet) { getOptimizableCRF(trainingSet); if (optimizer == null || optimizable != optimizer.getOptimizable()) { optimizer = new LimitedMemoryBFGS(threadedOptimizable); } return optimizer; }
private TransducerTrainer trainOnce(Pipe pipe, InstanceList examples) { Stopwatch watch = Stopwatch.createStarted(); CRF crf = new CRF(pipe, null); crf.addOrderNStates(examples, new int[]{1}, null, null, null, null, false); crf.addStartState(); crf.setWeightsDimensionAsIn(examples, true); if (initFrom != null) { crf.initializeApplicableParametersFrom(initFrom); } log.info("Starting syllchain training..."); CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8); trainer.setGaussianPriorVariance(2); trainer.setAddNoFactors(true); // trainer.setUseSomeUnsupportedTrick(true); trainer.train(examples); trainer.shutdown(); watch.stop(); log.info("SyllChain CRF Training took " + watch.toString()); crf.getInputAlphabet().stopGrowth(); crf.getOutputAlphabet().stopGrowth(); return trainer; }
getOptimizableCRF(trainingSet); // This will set this.mcrf if necessary getOptimizer(trainingSet); // This will set this.opt if necessary iterationCount++; logger.info ("CRF finished one iteration of maximizer, i="+i); runEvaluators(); } catch (IllegalArgumentException e) { e.printStackTrace();
public boolean trainIncremental (InstanceList training) { return train (training, Integer.MAX_VALUE); }