|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cc.mallet.fst.CRFOptimizableByBatchLabelLikelihood
public class CRFOptimizableByBatchLabelLikelihood
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).
Nested Class Summary | |
---|---|
static class |
CRFOptimizableByBatchLabelLikelihood.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 |
Field Summary | |
---|---|
protected java.util.List<double[]> |
cachedGradient
|
protected double[] |
cachedValue
|
protected CRF.Factors |
constraints
|
protected CRF |
crf
|
protected java.util.List<CRF.Factors> |
expectations
|
protected int |
numBatches
|
protected InstanceList |
trainingSet
|
Constructor Summary | |
---|---|
CRFOptimizableByBatchLabelLikelihood(CRF crf,
InstanceList ilist,
int numBatches)
|
Method Summary | |
---|---|
void |
combineGradients(java.util.Collection<double[]> batchGradients,
double[] buffer)
Adds gradients from all batches. |
protected void |
gatherConstraints(InstanceList ilist)
Set the constraints by running forward-backward with the output label sequence provided, thus restricting it to only those paths that agree with the label sequence. |
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. |
void |
getBatchValueGradient(double[] buffer,
int batchIndex,
int[] batchAssignments)
|
protected double |
getExpectationValue(int batchIndex,
int[] batchAssignments)
Computes log probability of a batch of training data, fill in corresponding expectations as well |
double |
getGaussianPriorVariance()
|
int |
getNumBatches()
|
int |
getNumParameters()
|
double |
getParameter(int index)
|
void |
getParameters(double[] buffer)
|
double |
getUseHyperbolicPriorSharpness()
|
double |
getUseHyperbolicPriorSlope()
|
void |
setGaussianPriorVariance(double p)
|
void |
setHyperbolicPriorSharpness(double p)
|
void |
setHyperbolicPriorSlope(double p)
|
void |
setParameter(int index,
double value)
|
void |
setParameters(double[] buff)
|
void |
setUseHyperbolicPrior(boolean f)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected CRF crf
protected InstanceList trainingSet
protected int numBatches
protected java.util.List<CRF.Factors> expectations
protected CRF.Factors constraints
protected double[] cachedValue
protected java.util.List<double[]> cachedGradient
Constructor Detail |
---|
public CRFOptimizableByBatchLabelLikelihood(CRF crf, InstanceList ilist, int numBatches)
Method Detail |
---|
protected void gatherConstraints(InstanceList ilist)
protected double getExpectationValue(int batchIndex, int[] batchAssignments)
public double getBatchValue(int batchIndex, int[] batchAssignments)
getBatchValue
in interface Optimizable.ByCombiningBatchGradient
public void getBatchValueGradient(double[] buffer, int batchIndex, int[] batchAssignments)
getBatchValueGradient
in interface Optimizable.ByCombiningBatchGradient
public void combineGradients(java.util.Collection<double[]> batchGradients, double[] buffer)
Note: assumes buffer is already initialized.
combineGradients
in interface Optimizable.ByCombiningBatchGradient
public int getNumBatches()
getNumBatches
in interface Optimizable.ByCombiningBatchGradient
public void setUseHyperbolicPrior(boolean f)
public void setHyperbolicPriorSlope(double p)
public void setHyperbolicPriorSharpness(double p)
public double getUseHyperbolicPriorSlope()
public double getUseHyperbolicPriorSharpness()
public void setGaussianPriorVariance(double p)
public double getGaussianPriorVariance()
public int getNumParameters()
getNumParameters
in interface Optimizable
public void getParameters(double[] buffer)
getParameters
in interface Optimizable
public double getParameter(int index)
getParameter
in interface Optimizable
public void setParameters(double[] buff)
setParameters
in interface Optimizable
public void setParameter(int index, double value)
setParameter
in interface Optimizable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |