edu.stanford.nlp.maxent.iis
Class LambdaSolve

java.lang.Object
  |
  +--edu.stanford.nlp.maxent.iis.LambdaSolve
Direct Known Subclasses:
LambdaSolveBinary, LambdaSolveTagger

public class LambdaSolve
extends Object

This is the main class that does the core computation in IIS.


Field Summary
 double eps
           
 boolean fixedFnumXY
          This flag is true if all (x,y) have the same f# in which case the newton equation solving is avoided
 byte[][] fnumArr
          This contains the number of features active for each pair (x,y)
 double[] ftieldArr
          This is an array of empirical expectations for the features
 double[] lambda
          These are the model parameters that have to be learned
 boolean[] lambda_converged
           
 double newtonerr
           
 Problem p
           
 double[][] probConds
          Conditional probabilities.
static boolean smooth
           
 double[] zlambda
          Normalization factors, one for each x
 
Constructor Summary
LambdaSolve()
           
LambdaSolve(Problem p1, double eps1, double nerr1)
           
LambdaSolve(String filename)
          reads the prameters from a file
 
Method Summary
 boolean checkCorrectness()
          Check whether the constraints are satisfied, the probabilities sum to one, etc.
protected  double fnum(int x, int y)
           
 double[] getDerivatives()
          assuming we have the lambdas in the array and we need only the derivatives now
 void ImprovedIterative()
          Iterate until convergence.
 void ImprovedIterative(int iters)
          Does a fixed number of IIS iterations
 double logLikelihood()
           
 double logLikelihoodScratch()
          calculate the log likelihood from scrath , hashing the conditional probabilities in pcond which we will use for the gradient later
static void main(String[] args)
          With arguments, this will print out the lambda paramters of a bunch of .lam files (which are assumed to all be the same size).
 double pcond(int y, int x)
           
 void print()
          Print out p(y|x) for all pairs to the standard output.
 void read(String filename)
          Read the model parameters from a file ( only the lambdas )
 void save_lambdas(String filename)
          Writes the lambdas to the file.
 void save(String filename)
          Saves xSize,ySize and the lambdas to the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lambda

public double[] lambda
These are the model parameters that have to be learned


lambda_converged

public boolean[] lambda_converged

eps

public double eps

newtonerr

public double newtonerr

fixedFnumXY

public boolean fixedFnumXY
This flag is true if all (x,y) have the same f# in which case the newton equation solving is avoided


p

public Problem p

probConds

public double[][] probConds
Conditional probabilities.


zlambda

public double[] zlambda
Normalization factors, one for each x


fnumArr

public byte[][] fnumArr
This contains the number of features active for each pair (x,y)


ftieldArr

public double[] ftieldArr
This is an array of empirical expectations for the features


smooth

public static boolean smooth
Constructor Detail

LambdaSolve

public LambdaSolve(Problem p1,
                   double eps1,
                   double nerr1)

LambdaSolve

public LambdaSolve(String filename)
reads the prameters from a file


LambdaSolve

public LambdaSolve()
Method Detail

ImprovedIterative

public void ImprovedIterative()
Iterate until convergence. I usually use the other method that does a fixed number of iterations.


ImprovedIterative

public void ImprovedIterative(int iters)
Does a fixed number of IIS iterations


pcond

public double pcond(int y,
                    int x)

fnum

protected double fnum(int x,
                      int y)

checkCorrectness

public boolean checkCorrectness()
Check whether the constraints are satisfied, the probabilities sum to one, etc. Prints out a message if there is something wrong.


print

public void print()
Print out p(y|x) for all pairs to the standard output.


save

public void save(String filename)
Saves xSize,ySize and the lambdas to the file. Can be read later with read(String).


save_lambdas

public void save_lambdas(String filename)
Writes the lambdas to the file. Can be read later with readL.


read

public void read(String filename)
Read the model parameters from a file ( only the lambdas )


logLikelihood

public double logLikelihood()
Returns:
The loglikelihood of the empirical distribution as predicted by the model p.

logLikelihoodScratch

public double logLikelihoodScratch()
calculate the log likelihood from scrath , hashing the conditional probabilities in pcond which we will use for the gradient later


getDerivatives

public double[] getDerivatives()
assuming we have the lambdas in the array and we need only the derivatives now


main

public static void main(String[] args)
With arguments, this will print out the lambda paramters of a bunch of .lam files (which are assumed to all be the same size).



Stanford NLP Group