edu.stanford.nlp.optimization
Class StochasticDiffFunctionTester

java.lang.Object
  extended by edu.stanford.nlp.optimization.StochasticDiffFunctionTester

public class StochasticDiffFunctionTester
extends Object

Author:
Alex Kleeman

Field Summary
protected  int numBatches
           
protected  int testBatchSize
           
protected  AbstractStochasticCachingDiffFunction thisFunc
           
 
Constructor Summary
StochasticDiffFunctionTester(Function function)
           
 
Method Summary
 void arrayToFile(double[] thisArray, String fileName)
           
 double[] getVariance(double[] x)
           
 double[] getVariance(double[] x, int batchSize)
           
 void listToFile(List<double[]> thisList, String fileName)
           
 double testConditionNumber(int samples)
           
 boolean testDerivatives(double[] x, double functionTolerance)
          This function tests to make sure that the sum of the stochastic calculated gradients is equal to the full gradient.
 boolean testSumOfBatches(double[] x, double functionTolerance)
          This function tests to make sure that the sum of the stochastic calculated gradients is equal to the full gradient.
 void testVariance(double[] x)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

testBatchSize

protected int testBatchSize

numBatches

protected int numBatches

thisFunc

protected AbstractStochasticCachingDiffFunction thisFunc
Constructor Detail

StochasticDiffFunctionTester

public StochasticDiffFunctionTester(Function function)
Method Detail

testSumOfBatches

public boolean testSumOfBatches(double[] x,
                                double functionTolerance)
This function tests to make sure that the sum of the stochastic calculated gradients is equal to the full gradient. This requires using ordered sampling, so if the ObjectiveFunction itself randomizes the inputs this function will likely fail.

Parameters:
x - is the point to evaluate the function at
functionTolerance - is the tolerance to place on the infinity norm of the gradient and value
Returns:
boolean indicating success or failure.

testDerivatives

public boolean testDerivatives(double[] x,
                               double functionTolerance)
This function tests to make sure that the sum of the stochastic calculated gradients is equal to the full gradient. This requires using ordered sampling, so if the ObjectiveFunction itself randomizes the inputs this function will likely fail.

Parameters:
x - is the point to evaluate the function at
functionTolerance - is the tolerance to place on the infinity norm of the gradient and value
Returns:
boolean indicating success or failure.

testConditionNumber

public double testConditionNumber(int samples)

getVariance

public double[] getVariance(double[] x)

getVariance

public double[] getVariance(double[] x,
                            int batchSize)

testVariance

public void testVariance(double[] x)

listToFile

public void listToFile(List<double[]> thisList,
                       String fileName)

arrayToFile

public void arrayToFile(double[] thisArray,
                        String fileName)


Stanford NLP Group