public void writeModel(File target) throws IOException { CRF crf = (CRF) lastTrainer.getTransducer(); ReadWrite.writeTo(new PhonemeCrfModel(crf), target); log.info("Wrote for whole data"); }
protected void preamble (TransducerTrainer tt) { int iteration = tt.getIteration(); String filename = filenamePrefix + "." + iteration + ".bin"; try { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(filename)); oos.writeObject(tt.getTransducer()); logger.info("Trained model saved: " + filename + ", iter: " + iteration); } catch (FileNotFoundException fnfe) { logger.warning("Could not save model: " + filename + ", iter: " + iteration); fnfe.printStackTrace(); } catch (IOException ioe) { logger.warning("Could not save model: " + filename + ", iter: " + iteration); ioe.printStackTrace(); } }
/** Train the transducer associated with this TransducerTrainer. * You should be able to call this method with different trainingSet objects. * Whether this causes the TransducerTrainer to combine both trainingSets or * to view the second as a new alternative is at the discretion of the particular * TransducerTrainer subclass involved. */ public abstract boolean train (InstanceList trainingSet, int numIterations);
protected void preamble (TransducerTrainer tt) { int iteration = tt.getIteration(); Optimizable opt; if (tt instanceof TransducerTrainer.ByOptimization && (opt = ((TransducerTrainer.ByOptimization)tt).getOptimizer().getOptimizable()) instanceof Optimizable.ByValue) logger.info ("Evaluator iteration="+iteration+" cost="+((Optimizable.ByValue)opt).getValue()); else logger.info ("Evaluator iteration="+iteration+" cost=NA (not Optimizable.ByValue)"); }
protected void preamble (TransducerTrainer tt) { int iteration = tt.getIteration(); Optimizable opt; if (tt instanceof TransducerTrainer.ByOptimization && (opt = ((TransducerTrainer.ByOptimization)tt).getOptimizer().getOptimizable()) instanceof Optimizable.ByValue) logger.info ("Evaluator iteration="+iteration+" cost="+((Optimizable.ByValue)opt).getValue()); else logger.info ("Evaluator iteration="+iteration+" cost=NA (not Optimizable.ByValue)"); }
public StressModel train(List<Alignment> aligns) { log.info("About to train the stress predictor..."); InstanceList examples = makeExamplesFromAligns(aligns); Pipe pipe = examples.getPipe(); log.info("Training test-time syll chain tagger on whole data..."); TransducerTrainer trainer = trainOnce(pipe, examples); return new StressModel((CRF) trainer.getTransducer()); }
protected void preamble (TransducerTrainer tt) { int iteration = tt.getIteration(); String filename = filenamePrefix + "." + iteration + ".bin"; try { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(filename)); oos.writeObject(tt.getTransducer()); logger.info("Trained model saved: " + filename + ", iter: " + iteration); } catch (FileNotFoundException fnfe) { logger.warning("Could not save model: " + filename + ", iter: " + iteration); fnfe.printStackTrace(); } catch (IOException ioe) { logger.warning("Could not save model: " + filename + ", iter: " + iteration); ioe.printStackTrace(); } }
protected void preamble (TransducerTrainer tt) { int iteration = tt.getIteration(); Optimizable opt; if (tt instanceof TransducerTrainer.ByOptimization && (opt = ((TransducerTrainer.ByOptimization)tt).getOptimizer().getOptimizable()) instanceof Optimizable.ByValue) logger.info ("Evaluator iteration="+iteration+" cost="+((Optimizable.ByValue)opt).getValue()); else logger.info ("Evaluator iteration="+iteration+" cost=NA (not Optimizable.ByValue)"); }
/** Train the transducer associated with this TransducerTrainer. * You should be able to call this method with different trainingSet objects. * Whether this causes the TransducerTrainer to combine both trainingSets or * to view the second as a new alternative is at the discretion of the particular * TransducerTrainer subclass involved. */ public abstract boolean train (InstanceList trainingSet, int numIterations);
public SyllChainModel train(List<Alignment> aligns) { log.info("About to train the syll chain..."); InstanceList examples = makeExamplesFromAligns(aligns); Pipe pipe = examples.getPipe(); log.info("Training test-time syll chain tagger on whole data..."); TransducerTrainer trainer = trainOnce(pipe, examples); return new SyllChainModel((CRF) trainer.getTransducer()); }
protected void preamble (TransducerTrainer tt) { int iteration = tt.getIteration(); String filename = filenamePrefix + "." + iteration + ".bin"; try { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(filename)); oos.writeObject(tt.getTransducer()); logger.info("Trained model saved: " + filename + ", iter: " + iteration); } catch (FileNotFoundException fnfe) { logger.warning("Could not save model: " + filename + ", iter: " + iteration); fnfe.printStackTrace(); } catch (IOException ioe) { logger.warning("Could not save model: " + filename + ", iter: " + iteration); ioe.printStackTrace(); } }
/** Train the transducer associated with this TransducerTrainer. * You should be able to call this method with different trainingSet objects. * Whether this causes the TransducerTrainer to combine both trainingSets or * to view the second as a new alternative is at the discretion of the particular * TransducerTrainer subclass involved. */ public abstract boolean train (InstanceList trainingSet, int numIterations);
public AlignTagModel train(Collection<Alignment> inputs) { InstanceList examples = makeExamplesFromAligns(inputs); Pipe pipe = examples.getPipe(); log.info("Training test-time aligner on whole data..."); TransducerTrainer trainer = trainOnce(pipe, examples); return new AlignTagModel((CRF) trainer.getTransducer()); }
@SuppressWarnings("unchecked") @Override public void evaluateInstanceList(TransducerTrainer transducerTrainer, InstanceList instances, String description) { int iteration = transducerTrainer.getIteration(); String viterbiFilename = filenamePrefix + description + iteration + ".viterbi"; PrintStream viterbiOutputStream; Sequence predOutput = transducerTrainer.getTransducer().transduce (input); assert (predOutput.size() == trueOutput.size());
public PhoneSyllTagModel train(Collection<SWord> inputs) { InstanceList examples = makeExamplesFromAligns(inputs); Pipe pipe = examples.getPipe(); log.info("Training test-time syll phone tagger on whole data..."); TransducerTrainer trainer = trainOnce(pipe, examples); return new PhoneSyllTagModel((CRF) trainer.getTransducer()); }
@SuppressWarnings("unchecked") @Override public void evaluateInstanceList(TransducerTrainer transducerTrainer, InstanceList instances, String description) { int iteration = transducerTrainer.getIteration(); String viterbiFilename = filenamePrefix + description + iteration + ".viterbi"; PrintStream viterbiOutputStream; Sequence predOutput = transducerTrainer.getTransducer().transduce (input); assert (predOutput.size() == trueOutput.size());
public void evaluateInstanceList (TransducerTrainer tt, InstanceList data, String description) Transducer model = tt.getTransducer(); int numCorrectTokens, totalTokens; int[] numTrueSegments, numPredictedSegments, numCorrectSegments;
@SuppressWarnings("unchecked") @Override public void evaluateInstanceList(TransducerTrainer transducerTrainer, InstanceList instances, String description) { int iteration = transducerTrainer.getIteration(); String viterbiFilename = filenamePrefix + description + iteration + ".viterbi"; PrintStream viterbiOutputStream; Sequence predOutput = transducerTrainer.getTransducer().transduce (input); assert (predOutput.size() == trueOutput.size());
public void evaluateInstanceList (TransducerTrainer tt, InstanceList data, String description) Transducer model = tt.getTransducer(); int numCorrectTokens, totalTokens; int[] numTrueSegments, numPredictedSegments, numCorrectSegments;
public void evaluateInstanceList (TransducerTrainer tt, InstanceList data, String description) Transducer model = tt.getTransducer(); int numCorrectTokens, totalTokens; int[] numTrueSegments, numPredictedSegments, numCorrectSegments;