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).
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classCRFOptimizableByBatchLabelLikelihood.Factory-
Nested classes/interfaces inherited from interface cc.mallet.optimize.Optimizable
Optimizable.ByBatchGradient, Optimizable.ByCombiningBatchGradient, Optimizable.ByGISUpdate, Optimizable.ByGradient, Optimizable.ByGradientValue, Optimizable.ByHessian, Optimizable.ByValue, Optimizable.ByVotedPerceptron
-
-
Constructor Summary
Constructors Constructor and Description CRFOptimizableByBatchLabelLikelihood(CRF crf, InstanceList ilist, int numBatches)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidcombineGradients(java.util.Collection<double[]> batchGradients, double[] buffer)Adds gradients from all batches.doublegetBatchValue(int batchIndex, int[] batchAssignments)Returns the log probability of a batch of training sequence labels and the prior over parameters, if last batch then incorporate the prior on parameters as well.voidgetBatchValueGradient(double[] buffer, int batchIndex, int[] batchAssignments)doublegetGaussianPriorVariance()intgetNumBatches()intgetNumParameters()doublegetParameter(int index)voidgetParameters(double[] buffer)doublegetUseHyperbolicPriorSharpness()doublegetUseHyperbolicPriorSlope()voidsetGaussianPriorVariance(double p)voidsetHyperbolicPriorSharpness(double p)voidsetHyperbolicPriorSlope(double p)voidsetParameter(int index, double value)voidsetParameters(double[] buff)voidsetUseHyperbolicPrior(boolean f)
-
-
-
Constructor Detail
-
CRFOptimizableByBatchLabelLikelihood
public CRFOptimizableByBatchLabelLikelihood(CRF crf, InstanceList ilist, int numBatches)
-
-
Method Detail
-
getBatchValue
public double getBatchValue(int batchIndex, int[] batchAssignments)Returns the log probability of a batch of training sequence labels and the prior over parameters, if last batch then incorporate the prior on parameters as well.- Specified by:
getBatchValuein interfaceOptimizable.ByCombiningBatchGradient
-
getBatchValueGradient
public void getBatchValueGradient(double[] buffer, int batchIndex, int[] batchAssignments)- Specified by:
getBatchValueGradientin interfaceOptimizable.ByCombiningBatchGradient
-
combineGradients
public void combineGradients(java.util.Collection<double[]> batchGradients, double[] buffer)Adds gradients from all batches.Note: assumes buffer is already initialized.
- Specified by:
combineGradientsin interfaceOptimizable.ByCombiningBatchGradient
-
getNumBatches
public int getNumBatches()
- Specified by:
getNumBatchesin interfaceOptimizable.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:
getNumParametersin interfaceOptimizable
-
getParameters
public void getParameters(double[] buffer)
- Specified by:
getParametersin interfaceOptimizable
-
getParameter
public double getParameter(int index)
- Specified by:
getParameterin interfaceOptimizable
-
setParameters
public void setParameters(double[] buff)
- Specified by:
setParametersin interfaceOptimizable
-
setParameter
public void setParameter(int index, double value)- Specified by:
setParameterin interfaceOptimizable
-
-
DataMelt 3.0 © DataMelt by jWork.ORG