cc.mallet.fst
Class CRFTrainerByThreadedLabelLikelihood

java.lang.Object
  extended by cc.mallet.fst.TransducerTrainer
      extended by cc.mallet.fst.CRFTrainerByThreadedLabelLikelihood
All Implemented Interfaces:
TransducerTrainer.ByOptimization

public class CRFTrainerByThreadedLabelLikelihood
extends TransducerTrainer
implements TransducerTrainer.ByOptimization

Author:
Gregory Druck gdruck@cs.umass.edu Multi-threaded version of CRF trainer. Note that multi-threaded feature induction and hyperbolic prior are not supported by this code.

Nested Class Summary
 
Nested classes/interfaces inherited from class cc.mallet.fst.TransducerTrainer
TransducerTrainer.ByIncrements, TransducerTrainer.ByInstanceIncrements, TransducerTrainer.ByOptimization
 
Constructor Summary
CRFTrainerByThreadedLabelLikelihood(CRF crf, int numThreads)
           
 
Method Summary
 CRF getCRF()
           
 double getGaussianPriorVariance()
           
 int getIteration()
           
 CRFOptimizableByBatchLabelLikelihood getOptimizableCRF(InstanceList trainingSet)
           
 Optimizer getOptimizer()
           
 Optimizer getOptimizer(InstanceList trainingSet)
           
 Transducer getTransducer()
           
 boolean getUseSparseWeights()
           
 boolean isConverged()
           
 boolean isFinishedTraining()
           
 void setAddNoFactors(boolean flag)
          Use this method to specify whether or not factors are added to the CRF by this trainer.
 void setGaussianPriorVariance(double p)
           
 void setUseSomeUnsupportedTrick(boolean b)
          Sets whether to use the 'some unsupported trick.' This trick is, if training a CRF where some training has been done and sparse weights are used, to add a few weights for feaures that do not occur in the tainig data.
 void setUseSparseWeights(boolean b)
           
 void shutdown()
           
 boolean train(InstanceList trainingSet, int numIterations)
          Train the transducer associated with this TransducerTrainer.
 boolean train(InstanceList training, int numIterationsPerProportion, double[] trainingProportions)
          Train a CRF on various-sized subsets of the data.
 boolean trainIncremental(InstanceList training)
           
 
Methods inherited from class cc.mallet.fst.TransducerTrainer
addEvaluator, addEvaluators, removeEvaluator, runEvaluators, train
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CRFTrainerByThreadedLabelLikelihood

public CRFTrainerByThreadedLabelLikelihood(CRF crf,
                                           int numThreads)
Method Detail

getTransducer

public Transducer getTransducer()
Specified by:
getTransducer in class TransducerTrainer

getCRF

public CRF getCRF()

getOptimizer

public Optimizer getOptimizer()
Specified by:
getOptimizer in interface TransducerTrainer.ByOptimization

isConverged

public boolean isConverged()

isFinishedTraining

public boolean isFinishedTraining()
Specified by:
isFinishedTraining in class TransducerTrainer

getIteration

public int getIteration()
Specified by:
getIteration in class TransducerTrainer

setGaussianPriorVariance

public void setGaussianPriorVariance(double p)

getGaussianPriorVariance

public double getGaussianPriorVariance()

setUseSparseWeights

public void setUseSparseWeights(boolean b)

getUseSparseWeights

public boolean getUseSparseWeights()

setUseSomeUnsupportedTrick

public void setUseSomeUnsupportedTrick(boolean b)
Sets whether to use the 'some unsupported trick.' This trick is, if training a CRF where some training has been done and sparse weights are used, to add a few weights for feaures that do not occur in the tainig data.

This generally leads to better accuracy at only a small memory cost.

Parameters:
b - Whether to use the trick

setAddNoFactors

public void setAddNoFactors(boolean flag)
Use this method to specify whether or not factors are added to the CRF by this trainer. If you have already setup the factors in your CRF, you may not want the trainer to add additional factors.

Parameters:
flag - If true, this trainer adds no factors to the CRF.

shutdown

public void shutdown()

getOptimizableCRF

public CRFOptimizableByBatchLabelLikelihood getOptimizableCRF(InstanceList trainingSet)

getOptimizer

public Optimizer getOptimizer(InstanceList trainingSet)

trainIncremental

public boolean trainIncremental(InstanceList training)

train

public boolean train(InstanceList trainingSet,
                     int numIterations)
Description copied from class: TransducerTrainer
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.

Specified by:
train in class TransducerTrainer

train

public boolean train(InstanceList training,
                     int numIterationsPerProportion,
                     double[] trainingProportions)
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.

Parameters:
training - The training Instances.
numIterationsPerProportion - Maximum number of Maximizer iterations per training proportion.
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.
Returns:
True if training has converged.