edu.stanford.nlp.parser.dvparser
Class DVParserCostAndGradient

java.lang.Object
  extended by edu.stanford.nlp.optimization.AbstractCachingDiffFunction
      extended by edu.stanford.nlp.parser.dvparser.DVParserCostAndGradient
All Implemented Interfaces:
DiffFunction, Function, HasInitial

public class DVParserCostAndGradient
extends AbstractCachingDiffFunction


Field Summary
 
Fields inherited from class edu.stanford.nlp.optimization.AbstractCachingDiffFunction
derivative, generator, value
 
Constructor Summary
DVParserCostAndGradient(java.util.List<Tree> trainingBatch, java.util.IdentityHashMap<Tree,java.util.List<Tree>> topParses, DVModel dvModel, Options op)
           
 
Method Summary
 void backpropDerivative(Tree tree, java.util.List<java.lang.String> words, java.util.IdentityHashMap<Tree,org.ejml.simple.SimpleMatrix> nodeVectors, TwoDimensionalMap<java.lang.String,java.lang.String,org.ejml.simple.SimpleMatrix> binaryW_dfs, java.util.Map<java.lang.String,org.ejml.simple.SimpleMatrix> unaryW_dfs, TwoDimensionalMap<java.lang.String,java.lang.String,org.ejml.simple.SimpleMatrix> binaryScoreDerivatives, java.util.Map<java.lang.String,org.ejml.simple.SimpleMatrix> unaryScoreDerivatives, java.util.Map<java.lang.String,org.ejml.simple.SimpleMatrix> wordVectorDerivatives)
           
 void backpropDerivative(Tree tree, java.util.List<java.lang.String> words, java.util.IdentityHashMap<Tree,org.ejml.simple.SimpleMatrix> nodeVectors, TwoDimensionalMap<java.lang.String,java.lang.String,org.ejml.simple.SimpleMatrix> binaryW_dfs, java.util.Map<java.lang.String,org.ejml.simple.SimpleMatrix> unaryW_dfs, TwoDimensionalMap<java.lang.String,java.lang.String,org.ejml.simple.SimpleMatrix> binaryScoreDerivatives, java.util.Map<java.lang.String,org.ejml.simple.SimpleMatrix> unaryScoreDerivatives, java.util.Map<java.lang.String,org.ejml.simple.SimpleMatrix> wordVectorDerivatives, org.ejml.simple.SimpleMatrix deltaUp)
           
 void calculate(double[] theta)
          Calculate the value at x and the derivative and save them in the respective fields.
static org.ejml.simple.SimpleMatrix concatenate(org.ejml.simple.SimpleMatrix... vectors)
          Concatenates several column vectors into one large column vector
static org.ejml.simple.SimpleMatrix concatenateWithBias(org.ejml.simple.SimpleMatrix... vectors)
          Concatenates several column vectors into one large column vector, adds a 1.0 at the end as a bias term
 int domainDimension()
          Returns the number of dimensions in the function's domain
static org.ejml.simple.SimpleMatrix elementwiseApplyNonlinearity(org.ejml.simple.SimpleMatrix input)
           
 java.util.List<DeepTree> getAllHighestScoringTreesTest(java.util.List<Tree> trees)
           
 DeepTree getHighestScoringTree(Tree tree, double lambda)
           
 double getMargin(Tree goldTree, Tree bestHypothesis)
           
static org.ejml.simple.SimpleMatrix nonlinearityVectorToDerivative(org.ejml.simple.SimpleMatrix input)
           
static void outputSpans(Tree tree)
           
 double score(Tree tree, java.util.IdentityHashMap<Tree,org.ejml.simple.SimpleMatrix> nodeVectors)
           
static double sigmoid(double x)
           
 
Methods inherited from class edu.stanford.nlp.optimization.AbstractCachingDiffFunction
clearCache, copy, derivativeAt, getDerivative, gradientCheck, gradientCheck, initial, lastValue, randomInitial, valueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DVParserCostAndGradient

public DVParserCostAndGradient(java.util.List<Tree> trainingBatch,
                               java.util.IdentityHashMap<Tree,java.util.List<Tree>> topParses,
                               DVModel dvModel,
                               Options op)
Method Detail

sigmoid

public static double sigmoid(double x)

elementwiseApplyNonlinearity

public static org.ejml.simple.SimpleMatrix elementwiseApplyNonlinearity(org.ejml.simple.SimpleMatrix input)

nonlinearityVectorToDerivative

public static org.ejml.simple.SimpleMatrix nonlinearityVectorToDerivative(org.ejml.simple.SimpleMatrix input)

concatenateWithBias

public static org.ejml.simple.SimpleMatrix concatenateWithBias(org.ejml.simple.SimpleMatrix... vectors)
Concatenates several column vectors into one large column vector, adds a 1.0 at the end as a bias term


concatenate

public static org.ejml.simple.SimpleMatrix concatenate(org.ejml.simple.SimpleMatrix... vectors)
Concatenates several column vectors into one large column vector


outputSpans

public static void outputSpans(Tree tree)

score

public double score(Tree tree,
                    java.util.IdentityHashMap<Tree,org.ejml.simple.SimpleMatrix> nodeVectors)

domainDimension

public int domainDimension()
Description copied from interface: Function
Returns the number of dimensions in the function's domain

Returns:
the number of domain dimensions

getAllHighestScoringTreesTest

public java.util.List<DeepTree> getAllHighestScoringTreesTest(java.util.List<Tree> trees)

getHighestScoringTree

public DeepTree getHighestScoringTree(Tree tree,
                                      double lambda)

calculate

public void calculate(double[] theta)
Description copied from class: AbstractCachingDiffFunction
Calculate the value at x and the derivative and save them in the respective fields.

Specified by:
calculate in class AbstractCachingDiffFunction
Parameters:
theta - The point at which to calculate the function

getMargin

public double getMargin(Tree goldTree,
                        Tree bestHypothesis)

backpropDerivative

public void backpropDerivative(Tree tree,
                               java.util.List<java.lang.String> words,
                               java.util.IdentityHashMap<Tree,org.ejml.simple.SimpleMatrix> nodeVectors,
                               TwoDimensionalMap<java.lang.String,java.lang.String,org.ejml.simple.SimpleMatrix> binaryW_dfs,
                               java.util.Map<java.lang.String,org.ejml.simple.SimpleMatrix> unaryW_dfs,
                               TwoDimensionalMap<java.lang.String,java.lang.String,org.ejml.simple.SimpleMatrix> binaryScoreDerivatives,
                               java.util.Map<java.lang.String,org.ejml.simple.SimpleMatrix> unaryScoreDerivatives,
                               java.util.Map<java.lang.String,org.ejml.simple.SimpleMatrix> wordVectorDerivatives)

backpropDerivative

public void backpropDerivative(Tree tree,
                               java.util.List<java.lang.String> words,
                               java.util.IdentityHashMap<Tree,org.ejml.simple.SimpleMatrix> nodeVectors,
                               TwoDimensionalMap<java.lang.String,java.lang.String,org.ejml.simple.SimpleMatrix> binaryW_dfs,
                               java.util.Map<java.lang.String,org.ejml.simple.SimpleMatrix> unaryW_dfs,
                               TwoDimensionalMap<java.lang.String,java.lang.String,org.ejml.simple.SimpleMatrix> binaryScoreDerivatives,
                               java.util.Map<java.lang.String,org.ejml.simple.SimpleMatrix> unaryScoreDerivatives,
                               java.util.Map<java.lang.String,org.ejml.simple.SimpleMatrix> wordVectorDerivatives,
                               org.ejml.simple.SimpleMatrix deltaUp)


Stanford NLP Group