Package cc.mallet.fst
Class CRFTrainerByValueGradients
- java.lang.Object
-
- cc.mallet.fst.TransducerTrainer
-
- cc.mallet.fst.CRFTrainerByValueGradients
-
- All Implemented Interfaces:
TransducerTrainer.ByOptimization
public class CRFTrainerByValueGradients extends TransducerTrainer implements TransducerTrainer.ByOptimization
A CRF trainer that can combine multiple objective functions, each represented by a Optmizable.ByValueGradient.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classCRFTrainerByValueGradients.OptimizableCRFAn optimizable CRF that contains a collection of objective functions.-
Nested classes/interfaces inherited from class cc.mallet.fst.TransducerTrainer
TransducerTrainer.ByIncrements, TransducerTrainer.ByInstanceIncrements, TransducerTrainer.ByOptimization
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_RESETS
-
Constructor Summary
Constructors Constructor Description CRFTrainerByValueGradients(CRF crf, Optimizable.ByGradientValue[] optimizableByValueGradientObjects)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CRFgetCRF()intgetIteration()Optimizable.ByGradientValue[]getOptimizableByGradientValueObjects()CRFTrainerByValueGradients.OptimizableCRFgetOptimizableCRF(InstanceList trainingSet)Returns an optimizable CRF that contains a collection of objective functions.OptimizergetOptimizer()OptimizergetOptimizer(InstanceList trainingSet)Returns a L-BFGS optimizer, creating if one doesn't exist.TransducergetTransducer()booleanisConverged()Returns true if training converged, false otherwise.booleanisFinishedTraining()Returns true if training converged, false otherwise.voidsetMaxResets(int maxResets)Sets the max.booleantrain(InstanceList trainingSet, int numIterations)Trains a CRF until convergence or specified number of iterations, whichever is earlier.booleantrain(InstanceList training, int numIterationsPerProportion, double[] trainingProportions)Train a CRF on various-sized subsets of the data.booleantrainIncremental(InstanceList training)Trains a CRF until convergence.-
Methods inherited from class cc.mallet.fst.TransducerTrainer
addEvaluator, addEvaluators, removeEvaluator, runEvaluators, train
-
-
-
-
Field Detail
-
DEFAULT_MAX_RESETS
public static final int DEFAULT_MAX_RESETS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CRFTrainerByValueGradients
public CRFTrainerByValueGradients(CRF crf, Optimizable.ByGradientValue[] optimizableByValueGradientObjects)
-
-
Method Detail
-
getTransducer
public Transducer getTransducer()
- Specified by:
getTransducerin classTransducerTrainer
-
getCRF
public CRF getCRF()
-
getOptimizer
public Optimizer getOptimizer()
- Specified by:
getOptimizerin interfaceTransducerTrainer.ByOptimization
-
isConverged
public boolean isConverged()
Returns true if training converged, false otherwise.
-
isFinishedTraining
public boolean isFinishedTraining()
Returns true if training converged, false otherwise.- Specified by:
isFinishedTrainingin classTransducerTrainer
-
getIteration
public int getIteration()
- Specified by:
getIterationin classTransducerTrainer
-
getOptimizableByGradientValueObjects
public Optimizable.ByGradientValue[] getOptimizableByGradientValueObjects()
-
getOptimizableCRF
public CRFTrainerByValueGradients.OptimizableCRF getOptimizableCRF(InstanceList trainingSet)
Returns an optimizable CRF that contains a collection of objective functions.If one doesn't exist then creates one and sets the optimizer to null.
-
getOptimizer
public Optimizer getOptimizer(InstanceList trainingSet)
Returns a L-BFGS optimizer, creating if one doesn't exist.Also creates an optimizable CRF if required.
-
trainIncremental
public boolean trainIncremental(InstanceList training)
Trains a CRF until convergence.
-
train
public boolean train(InstanceList trainingSet, int numIterations)
Trains a CRF until convergence or specified number of iterations, whichever is earlier.Also creates an optimizable CRF and an optmizer if required.
- Specified by:
trainin classTransducerTrainer
-
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.
-
setMaxResets
public void setMaxResets(int maxResets)
Sets the max. number of times the optimizer can be reset before throwing an exception.Default value: DEFAULT_MAX_RESETS.
-
-