edu.stanford.nlp.ie.crf
Class CRFLogConditionalObjectiveFunction
java.lang.Object
edu.stanford.nlp.optimization.AbstractCachingDiffFunction
edu.stanford.nlp.optimization.AbstractStochasticCachingDiffFunction
edu.stanford.nlp.ie.crf.CRFLogConditionalObjectiveFunction
- All Implemented Interfaces:
- DiffFunction, Function, HasInitial
public class CRFLogConditionalObjectiveFunction
- extends AbstractStochasticCachingDiffFunction
- Author:
- Jenny Finkel
Fields inherited from class edu.stanford.nlp.optimization.AbstractStochasticCachingDiffFunction |
allIndices, curElement, extFiniteDiffDerivative, finiteDifferenceStepSize, gradPerturbed, hasNewVals, HdotV, lastBatch, lastBatchSize, lastElement, lastVBatch, lastXBatch, method, randGenerator, recalculatePrevBatch, returnPreviousValues, sampleMethod, scaleUp, xPerturbed |
Method Summary |
void |
calculate(double[] x)
Calculates both value and partial derivatives at the point x, and save them internally. |
void |
calculateStochastic(double[] x,
double[] v,
int[] batch)
calculateStochastic needs to calculate a stochastic approximation to the derivative and value of
of a function for a given batch of the data. |
void |
calculateStochasticGradientOnly(double[] x,
int[] batch)
|
int |
dataDimension()
Data dimension must return the size of the data used by the function. |
int |
domainDimension()
Returns the number of dimensions in the function's domain |
double[][] |
empty2D()
|
double[] |
to1D(double[][] weights)
|
double[][] |
to2D(double[] weights)
Takes a double array of weights which and creates a 2D array where:
the first element is the mapped index of featuresIndex
the second element is the index of the of the element |
Methods inherited from class edu.stanford.nlp.optimization.AbstractStochasticCachingDiffFunction |
clearCache, copy, decrementBatch, derivativeAt, derivativeAt, HdotVAt, HdotVAt, HdotVAt, incrementBatch, incrementRandom, initial, lastDerivative, lastValue, scaleUp, setValue, valueAt, valueAt |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NO_PRIOR
public static final int NO_PRIOR
- See Also:
- Constant Field Values
QUADRATIC_PRIOR
public static final int QUADRATIC_PRIOR
- See Also:
- Constant Field Values
HUBER_PRIOR
public static final int HUBER_PRIOR
- See Also:
- Constant Field Values
QUARTIC_PRIOR
public static final int QUARTIC_PRIOR
- See Also:
- Constant Field Values
prior
protected int prior
sigma
protected double sigma
epsilon
protected double epsilon
VERBOSE
public static boolean VERBOSE
domainDimension
public int domainDimension()
- Description copied from interface:
Function
- Returns the number of dimensions in the function's domain
- Specified by:
domainDimension
in interface Function
- Specified by:
domainDimension
in class AbstractCachingDiffFunction
- Returns:
- the number of domain dimensions
to2D
public double[][] to2D(double[] weights)
- Takes a double array of weights which and creates a 2D array where:
the first element is the mapped index of featuresIndex
the second element is the index of the of the element
- Parameters:
weights
-
- Returns:
- a 2D weight array
to1D
public double[] to1D(double[][] weights)
empty2D
public double[][] empty2D()
calculate
public void calculate(double[] x)
- Calculates both value and partial derivatives at the point x, and save them internally.
- Specified by:
calculate
in class AbstractCachingDiffFunction
- Parameters:
x
-
calculateStochastic
public void calculateStochastic(double[] x,
double[] v,
int[] batch)
- Description copied from class:
AbstractStochasticCachingDiffFunction
- calculateStochastic needs to calculate a stochastic approximation to the derivative and value of
of a function for a given batch of the data. The approximation to the derivative must be stored
in the array
derivative
, the approximation to the value in value
and the approximation to the Hessian vector product H.v in the array HdotV
. Note
that the hessian vector product is used primarily with the Stochastic Meta Descent optimization
routine SMDMinimizer
.
Important: The stochastic approximation must be such that the sum of all stochastic calculations over
each of the batches in the data must equal the full calculation. i.e. for a data set of size 100
the sum of the gradients for batches 1-10 , 11-20 , 21-30 .... 91-100 must be the same as the gradient
for the full calculation (at the very least in expectation). Be sure to take into account the priors.
- Specified by:
calculateStochastic
in class AbstractStochasticCachingDiffFunction
- Parameters:
x
- - value to evaluate atv
- - the vector for the Hessian vector product H.vbatch
- - an array containing the indices of the data to use in the calculation, this array is being calculated
internal to the abstract, and only needs to be handled not generated by the implemenation.
dataDimension
public int dataDimension()
- Description copied from class:
AbstractStochasticCachingDiffFunction
- Data dimension must return the size of the data used by the function.
- Specified by:
dataDimension
in class AbstractStochasticCachingDiffFunction
- Returns:
calculateStochasticGradientOnly
public void calculateStochasticGradientOnly(double[] x,
int[] batch)
Stanford NLP Group