edu.stanford.nlp.maxent
Class CGRunner

java.lang.Object
  extended by edu.stanford.nlp.maxent.CGRunner

public class CGRunner
extends java.lang.Object

This class will call an optimization method such as Conjugate Gradient or Quasi-Newton on a LambdaSolve object to find optimal parameters, including imposing a Gaussian prior on those parameters.

Author:
Kristina Toutanova, Christopher Manning

Constructor Summary
CGRunner(LambdaSolve prob, java.lang.String filename)
          Set up a LambdaSolve problem for solution by a Minimizer.
CGRunner(LambdaSolve prob, java.lang.String filename, double priorSigmaS)
          Set up a LambdaSolve problem for solution by a Minimizer, specifying a value for sigma2.
CGRunner(LambdaSolve prob, java.lang.String filename, double tol, double priorSigmaS)
          Set up a LambdaSolve problem for solution by a Minimizer.
CGRunner(LambdaSolve prob, java.lang.String filename, double tol, double[] sigmaSquareds)
          Set up a LambdaSolve problem for solution by a Minimizer.
 
Method Summary
 void solveCG()
          Solves the problem using conjugate gradient (CG).
 void solveL1(double weight)
          Solves the problem using OWLQN.
 void solveOWLQN2(double weight)
           
 void solveQN()
          Solves the problem using a quasi-newton method (L-BFGS).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CGRunner

public CGRunner(LambdaSolve prob,
                java.lang.String filename)
Set up a LambdaSolve problem for solution by a Minimizer. Uses a Gaussian prior with a sigma2 of 0.5.

Parameters:
prob - The problem to solve
filename - Used (with extension) to save intermediate results.

CGRunner

public CGRunner(LambdaSolve prob,
                java.lang.String filename,
                double priorSigmaS)
Set up a LambdaSolve problem for solution by a Minimizer, specifying a value for sigma2.

Parameters:
prob - The problem to solve
filename - Used (with extension) to save intermediate results.
priorSigmaS - The prior sigma2: this doubled will be used to divide the lambda2 values as the prior penalty in the likelihood. A value of 0.0 or Double.POSITIVE_INFINITY indicates to not use regularization.

CGRunner

public CGRunner(LambdaSolve prob,
                java.lang.String filename,
                double tol,
                double priorSigmaS)
Set up a LambdaSolve problem for solution by a Minimizer.

Parameters:
prob - The problem to solve
filename - Used (with extension) to save intermediate results.
tol - Tolerance of errors (passed to CG)
priorSigmaS - The prior sigma2: this doubled will be used to divide the lambda2 values as the prior penalty. A value of 0.0 or Double.POSITIVE_INFINITY indicates to not use regularization.

CGRunner

public CGRunner(LambdaSolve prob,
                java.lang.String filename,
                double tol,
                double[] sigmaSquareds)
Set up a LambdaSolve problem for solution by a Minimizer.

Parameters:
prob - The problem to solve
filename - Used (with extension) to save intermediate results.
tol - Tolerance of errors (passed to CG)
sigmaSquareds - The prior sigma2 for each feature: this doubled will be used to divide the lambda2 values as the prior penalty. This array must have size the number of features. If it is null, no regularization will be performed.
Method Detail

solveQN

public void solveQN()
Solves the problem using a quasi-newton method (L-BFGS). The solution is stored in the lambda array of prob.


solveOWLQN2

public void solveOWLQN2(double weight)

solveCG

public void solveCG()
Solves the problem using conjugate gradient (CG). The solution is stored in the lambda array of prob.


solveL1

public void solveL1(double weight)
Solves the problem using OWLQN. The solution is stored in the lambda array of prob. Note that the likelihood function will be a penalized L2 likelihood function unless you have turned this off via setting the priorSigmaS to 0.0.

Parameters:
weight - Controls the sparseness/regularization of the L1 solution. The bigger the number the sparser the solution. Weights between 0.01 and 1.0 typically give good performance.


Stanford NLP Group