edu.stanford.nlp.maxent
Class CGRunner

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

public class CGRunner
extends 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, String filename)
          Set up a LambdaSolve problem for solution by Conjugate Gradient.
CGRunner(LambdaSolve prob, String filename, double priorSigmaS)
          Set up a LambdaSolve problem for solution by Conjugate Gradient, specifying a value for sigma2.
CGRunner(LambdaSolve prob, String filename, double tol, double priorSigmaS)
          Set up a LambdaSolve problem for solution by Conjugate Gradient.
CGRunner(LambdaSolve prob, String filename, double tol, double[] sigmaSquareds)
          Set up a LambdaSolve problem for solution by Conjugate Gradient.
 
Method Summary
 void solve()
          Solves the problem using QN.
 void solveCG()
          Solves the problem using CG.
 void solveL1(double weight)
          Solves the problem using OWLQN.
 void solveQN()
          Solves the problem using QN.
 
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,
                String filename)
Set up a LambdaSolve problem for solution by Conjugate Gradient. 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,
                String filename,
                double priorSigmaS)
Set up a LambdaSolve problem for solution by Conjugate Gradient, 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,
                String filename,
                double tol,
                double priorSigmaS)
Set up a LambdaSolve problem for solution by Conjugate Gradient.

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,
                String filename,
                double tol,
                double[] sigmaSquareds)
Set up a LambdaSolve problem for solution by Conjugate Gradient.

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 eah 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

solve

public void solve()
Solves the problem using QN. The solution is stored in the lambda array of prob.


solveQN

public void solveQN()
Solves the problem using QN. The solution is stored in the lambda array of prob.


solveCG

public void solveCG()
Solves the problem using 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