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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
CRFTrainerByStochasticGradient
public CRFTrainerByStochasticGradient(CRF crf,
InstanceList trainingSample)
CRFTrainerByStochasticGradient
public CRFTrainerByStochasticGradient(CRF crf,
double learningRate)
getIteration
public int getIteration()
- Specified by:
getIteration
in class TransducerTrainer
getTransducer
public Transducer getTransducer()
- Specified by:
getTransducer
in class TransducerTrainer
isFinishedTraining
public boolean isFinishedTraining()
- Specified by:
isFinishedTraining
in class TransducerTrainer
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 class TransducerTrainer
train
public boolean train(InstanceList trainingSet,
int numIterations,
int numIterationsBetweenEvaluation)
trainIncremental
public boolean trainIncremental(InstanceList trainingSet)
- Specified by:
trainIncremental
in class TransducerTrainer.ByIncrements
trainIncremental
public boolean trainIncremental(Instance trainingInstance)
- Specified by:
trainIncremental
in class TransducerTrainer.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.