Package cc.mallet.fst
Class CRFTrainerByStochasticGradient
- java.lang.Object
-
- cc.mallet.fst.TransducerTrainer
-
- cc.mallet.fst.TransducerTrainer.ByIncrements
-
- cc.mallet.fst.TransducerTrainer.ByInstanceIncrements
-
- cc.mallet.fst.CRFTrainerByStochasticGradient
-
public class CRFTrainerByStochasticGradient extends TransducerTrainer.ByInstanceIncrements
Trains CRF by stochastic gradient. Most effective on large training sets.- Author:
- kedarb
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class cc.mallet.fst.TransducerTrainer
TransducerTrainer.ByIncrements, TransducerTrainer.ByInstanceIncrements, TransducerTrainer.ByOptimization
-
-
Field Summary
Fields Modifier and Type Field Description protected CRF.Factors
constraints
protected boolean
converged
protected CRF
crf
protected CRF.Factors
expectations
protected int
iterationCount
protected double
lambda
protected double
learningRate
protected double
t
-
Constructor Summary
Constructors Constructor Description CRFTrainerByStochasticGradient(CRF crf, double learningRate)
CRFTrainerByStochasticGradient(CRF crf, InstanceList trainingSample)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getIteration()
double
getLearningRate()
Transducer
getTransducer()
boolean
isFinishedTraining()
void
setLearningRate(double r)
void
setLearningRateByLikelihood(InstanceList trainingSample)
Automatically sets the learning rate to one that would be goodboolean
train(InstanceList trainingSet, int numIterations)
Train the transducer associated with this TransducerTrainer.boolean
train(InstanceList trainingSet, int numIterations, int numIterationsBetweenEvaluation)
boolean
trainIncremental(Instance trainingInstance)
boolean
trainIncremental(InstanceList trainingSet)
double
trainIncrementalLikelihood(Instance trainingInstance)
Adjust the parameters by default learning rate according to the gradient of this single Instance, and return the true label sequence likelihood.double
trainIncrementalLikelihood(Instance trainingInstance, double rate)
Adjust the parameters by learning rate according to the gradient of this single Instance, and return the true label sequence likelihood.-
Methods inherited from class cc.mallet.fst.TransducerTrainer
addEvaluator, addEvaluators, removeEvaluator, runEvaluators, train
-
-
-
-
Field Detail
-
crf
protected CRF crf
-
learningRate
protected double learningRate
-
t
protected double t
-
lambda
protected double lambda
-
iterationCount
protected int iterationCount
-
converged
protected boolean converged
-
expectations
protected CRF.Factors expectations
-
constraints
protected CRF.Factors constraints
-
-
Constructor Detail
-
CRFTrainerByStochasticGradient
public CRFTrainerByStochasticGradient(CRF crf, InstanceList trainingSample)
-
CRFTrainerByStochasticGradient
public CRFTrainerByStochasticGradient(CRF crf, double learningRate)
-
-
Method Detail
-
getIteration
public int getIteration()
- Specified by:
getIteration
in classTransducerTrainer
-
getTransducer
public Transducer getTransducer()
- Specified by:
getTransducer
in classTransducerTrainer
-
isFinishedTraining
public boolean isFinishedTraining()
- Specified by:
isFinishedTraining
in classTransducerTrainer
-
setLearningRateByLikelihood
public void setLearningRateByLikelihood(InstanceList trainingSample)
Automatically sets the learning rate to one that would be good
-
setLearningRate
public void setLearningRate(double r)
-
getLearningRate
public double getLearningRate()
-
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 classTransducerTrainer
-
train
public boolean train(InstanceList trainingSet, int numIterations, int numIterationsBetweenEvaluation)
-
trainIncremental
public boolean trainIncremental(InstanceList trainingSet)
- Specified by:
trainIncremental
in classTransducerTrainer.ByIncrements
-
trainIncremental
public boolean trainIncremental(Instance trainingInstance)
- Specified by:
trainIncremental
in classTransducerTrainer.ByInstanceIncrements
-
trainIncrementalLikelihood
public double trainIncrementalLikelihood(Instance trainingInstance)
Adjust the parameters by default learning rate according to the gradient of this single Instance, and return the true label sequence likelihood.
-
trainIncrementalLikelihood
public double trainIncrementalLikelihood(Instance trainingInstance, double rate)
Adjust the parameters by learning rate according to the gradient of this single Instance, and return the true label sequence likelihood.
-
-