Skip to content

Commit

Permalink
Minor cleanup. Closes #325.
Browse files Browse the repository at this point in the history
  • Loading branch information
manning authored and Stanford NLP committed Jan 7, 2017
1 parent 61d4228 commit ac505c7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/edu/stanford/nlp/sentiment/SentimentCostAndGradient.java
Expand Up @@ -2,7 +2,6 @@

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.ejml.simple.SimpleMatrix;

Expand All @@ -22,7 +21,8 @@
// TODO: get rid of the word Sentiment everywhere
public class SentimentCostAndGradient extends AbstractCachingDiffFunction {

private static Redwood.RedwoodChannels log = Redwood.channels(SentimentCostAndGradient.class);
private static final Redwood.RedwoodChannels log = Redwood.channels(SentimentCostAndGradient.class);

private final SentimentModel model;
private final List<Tree> trainingBatch;

Expand Down Expand Up @@ -52,7 +52,7 @@ private static double sumError(Tree tree) {
}

/**
* Returns the index with the highest value in the <code>predictions</code> matrix.
* Returns the index with the highest value in the {@code predictions} matrix.
* Indexed from 0.
*/
private static int getPredictedClass(SimpleMatrix predictions) {
Expand Down Expand Up @@ -287,7 +287,7 @@ public void calculate(double[] theta) {
derivative = NeuralUtils.paramsToVector(theta.length, derivatives.binaryTD.valueIterator(), derivatives.binaryCD.valueIterator(), SimpleTensor.iteratorSimpleMatrix(derivatives.binaryTensorTD.valueIterator()), derivatives.unaryCD.values().iterator(), derivatives.wordVectorD.values().iterator());
}

static double scaleAndRegularize(TwoDimensionalMap<String, String, SimpleMatrix> derivatives,
private static double scaleAndRegularize(TwoDimensionalMap<String, String, SimpleMatrix> derivatives,
TwoDimensionalMap<String, String, SimpleMatrix> currentMatrices,
double scale, double regCost, boolean dropBiasColumn) {
double cost = 0.0; // the regularization cost
Expand All @@ -305,9 +305,9 @@ static double scaleAndRegularize(TwoDimensionalMap<String, String, SimpleMatrix>
return cost;
}

static double scaleAndRegularize(Map<String, SimpleMatrix> derivatives,
private static double scaleAndRegularize(Map<String, SimpleMatrix> derivatives,
Map<String, SimpleMatrix> currentMatrices,
double scale, double regCost,
double scale, double regCost,
boolean activeMatricesOnly, boolean dropBiasColumn) {
double cost = 0.0; // the regularization cost
for (Map.Entry<String, SimpleMatrix> entry : currentMatrices.entrySet()) {
Expand All @@ -330,7 +330,7 @@ static double scaleAndRegularize(Map<String, SimpleMatrix> derivatives,
return cost;
}

static double scaleAndRegularizeTensor(TwoDimensionalMap<String, String, SimpleTensor> derivatives,
private static double scaleAndRegularizeTensor(TwoDimensionalMap<String, String, SimpleTensor> derivatives,
TwoDimensionalMap<String, String, SimpleTensor> currentMatrices,
double scale,
double regCost) {
Expand Down Expand Up @@ -486,8 +486,8 @@ private static SimpleTensor getTensorGradient(SimpleMatrix deltaFull, SimpleMatr
* useful annotation except when training.
*/
public void forwardPropagateTree(Tree tree) {
SimpleMatrix nodeVector = null;
SimpleMatrix classification = null;
SimpleMatrix nodeVector; // initialized below or Exception thrown // = null;
SimpleMatrix classification; // initialized below or Exception thrown // = null;

if (tree.isLeaf()) {
// We do nothing for the leaves. The preterminals will
Expand Down

0 comments on commit ac505c7

Please sign in to comment.