cc.mallet.fst
Class CRFOptimizableByBatchLabelLikelihood
java.lang.Object
cc.mallet.fst.CRFOptimizableByBatchLabelLikelihood
- All Implemented Interfaces:
- Optimizable, Optimizable.ByCombiningBatchGradient, java.io.Serializable
public class CRFOptimizableByBatchLabelLikelihood
- extends java.lang.Object
- implements Optimizable.ByCombiningBatchGradient, java.io.Serializable
Implements label likelihood gradient computations for batches of data, can be
easily parallelized.
The gradient computations are the same as that of
CRFOptimizableByLabelLikelihood.
*Note*: Expectations corresponding to each batch of data can be computed in
parallel. During gradient computation, the prior and the constraints are
incorporated into the expectations of the last batch (see
getBatchValue, getBatchValueGradient).
*Note*: This implementation ignores instances with infinite weights (see
getExpectationValue).
- Author:
- Gaurav Chandalia
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
crf
protected CRF crf
trainingSet
protected InstanceList trainingSet
numBatches
protected int numBatches
expectations
protected java.util.List<CRF.Factors> expectations
constraints
protected CRF.Factors constraints
cachedValue
protected double[] cachedValue
cachedGradient
protected java.util.List<double[]> cachedGradient
CRFOptimizableByBatchLabelLikelihood
public CRFOptimizableByBatchLabelLikelihood(CRF crf,
InstanceList ilist,
int numBatches)
gatherConstraints
protected void gatherConstraints(InstanceList ilist)
getExpectationValue
protected double getExpectationValue(int batchIndex,
int[] batchAssignments)
getBatchValue
public double getBatchValue(int batchIndex,
int[] batchAssignments)
- Specified by:
getBatchValue in interface Optimizable.ByCombiningBatchGradient
getBatchValueGradient
public void getBatchValueGradient(double[] buffer,
int batchIndex,
int[] batchAssignments)
- Specified by:
getBatchValueGradient in interface Optimizable.ByCombiningBatchGradient
combineGradients
public void combineGradients(java.util.Collection<double[]> batchGradients,
double[] buffer)
- Specified by:
combineGradients in interface Optimizable.ByCombiningBatchGradient
getNumBatches
public int getNumBatches()
- Specified by:
getNumBatches in interface Optimizable.ByCombiningBatchGradient
setUseHyperbolicPrior
public void setUseHyperbolicPrior(boolean f)
setHyperbolicPriorSlope
public void setHyperbolicPriorSlope(double p)
setHyperbolicPriorSharpness
public void setHyperbolicPriorSharpness(double p)
getUseHyperbolicPriorSlope
public double getUseHyperbolicPriorSlope()
getUseHyperbolicPriorSharpness
public double getUseHyperbolicPriorSharpness()
setGaussianPriorVariance
public void setGaussianPriorVariance(double p)
getGaussianPriorVariance
public double getGaussianPriorVariance()
getNumParameters
public int getNumParameters()
- Specified by:
getNumParameters in interface Optimizable
getParameters
public void getParameters(double[] buffer)
- Specified by:
getParameters in interface Optimizable
getParameter
public double getParameter(int index)
- Specified by:
getParameter in interface Optimizable
setParameters
public void setParameters(double[] buff)
- Specified by:
setParameters in interface Optimizable
setParameter
public void setParameter(int index,
double value)
- Specified by:
setParameter in interface Optimizable