cc.mallet.fst
Class CRFTrainerByStochasticGradient

java.lang.Object
  extended by cc.mallet.fst.TransducerTrainer
      extended by cc.mallet.fst.TransducerTrainer.ByIncrements
          extended by cc.mallet.fst.TransducerTrainer.ByInstanceIncrements
              extended by 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
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
CRFTrainerByStochasticGradient(CRF crf, double learningRate)
           
CRFTrainerByStochasticGradient(CRF crf, InstanceList trainingSample)
           
 
Method Summary
 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 good
 boolean 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 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.