|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcalhoun.analysis.crf.solver.StandardOptimizer
public class StandardOptimizer
uses a L-BFGS algorithm to optimize the objective function. This is the algorithm normally used. Several configuration parameters all you to control optimization parameters:
This optimizer requires one property to be set:
gradFunc - This is the gradient function that the optimizer will use. It must be a reference to a bean that implements the CRFObjectiveFunctionGradient interface.
In addition, it has several optional properties that allow control over the optimization process:
debugLevel - explicitly sets the debug level in the underlying L-BFGS solver. Normally it is set based
on the debug level for this object.
epsForConvergence - epsilon value used to determine when to halt the optimzation and declase convergence. Defaults
to 0.0001.
fixFirstWeight - if true, the first feature weight will be fixed at 1.0 and will not be allowed to change
during the optimization
maxIters - The maximum number of iterations (objective function evaluations) to attempt
mForHessian - sets the mForHession parameter in the underlying L-BFGS solver. Defaults to 20.
quadraticRegularization - if set to a nonzero value, regularizes feature weights by imposing
a penalty on the objective function based on the absolute sizes of the weights. Can help in cases where weights
get very large.
requireConverge - if true, throws an error if convergence is not reached in the maximum number
of iterations. Otherwise, the current feature weights are returned when maxIters is reached.
starts - an initial set of guesses at feature weights. Defaults to 1.0
unchangedObjective - the number of times the objectiveFunction must return an identical value before the optimization is assumed to have converged.
This protects against a situation where the epsForConvergence is set low enough that even the smallest possible changes in weights can't find an optimum. Defaults to 5
| Constructor Summary | |
|---|---|
StandardOptimizer()
|
|
| Method Summary | |
|---|---|
int |
getDebugLevel()
|
double |
getEpsForConvergence()
|
int |
getMaxIters()
|
int |
getMForHessian()
|
CRFObjectiveFunctionGradient |
getObjectiveFunction()
returns the configured objective function gradient which will be used by the optimizer during the training process. |
double |
getQuadraticRegularization()
|
double[] |
getStarts()
|
int |
getUnchangedObjective()
|
boolean |
isFixFirstWeight()
|
boolean |
isRequireConvergence()
|
double[] |
optimize(ModelManager fm,
java.util.List<? extends TrainingSequence<?>> data)
find the set of weights which maximizes the value of the objective function. |
void |
setDebugLevel(int debugLevel)
|
void |
setEpsForConvergence(double epsForConvergence)
|
void |
setFixFirstWeight(boolean fixFirstWeight)
|
void |
setMaxIters(int maxIters)
|
void |
setMForHessian(int forHessian)
|
void |
setObjectiveFunction(CRFObjectiveFunctionGradient objectiveFunction)
sets the objective function gradient. |
void |
setQuadraticRegularization(double quadraticRegularization)
|
void |
setRequireConvergence(boolean requireConvergence)
|
void |
setStarts(double[] starts)
Sets the starting weights for the optimization. |
void |
setUnchangedObjective(int unchangedObjective)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StandardOptimizer()
| Method Detail |
|---|
public double[] optimize(ModelManager fm,
java.util.List<? extends TrainingSequence<?>> data)
CRFTrainingCRFObjectiveFunctionGradient object will already
be configured witht eh appropriate training data, so it appears here as a pure function evaluation.
optimize in interface CRFTrainingfm - the model to train on.data - the training data to use for training.
public CRFObjectiveFunctionGradient getObjectiveFunction()
public void setObjectiveFunction(CRFObjectiveFunctionGradient objectiveFunction)
public int getDebugLevel()
public void setDebugLevel(int debugLevel)
public double getEpsForConvergence()
public void setEpsForConvergence(double epsForConvergence)
public boolean isFixFirstWeight()
public void setFixFirstWeight(boolean fixFirstWeight)
public int getMaxIters()
public void setMaxIters(int maxIters)
public int getMForHessian()
public void setMForHessian(int forHessian)
public double getQuadraticRegularization()
public void setQuadraticRegularization(double quadraticRegularization)
public boolean isRequireConvergence()
public void setRequireConvergence(boolean requireConvergence)
public double[] getStarts()
public void setStarts(double[] starts)
CRFTraining
setStarts in interface CRFTrainingstarts - an array of weights to use as the starting point for the optimizer. The optimzier is not required to use this as a starting point.public int getUnchangedObjective()
public void setUnchangedObjective(int unchangedObjective)
unchangedObjective - The unchangedObjective to set.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||