Search in sources :

Example 71 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project CoreNLP by stanfordnlp.

the class SentimentPipeline method outputTreeScores.

/**
 * Outputs the scores from the tree.  Counts the tree nodes the
 * same as setIndexLabels.
 */
private static int outputTreeScores(PrintStream out, Tree tree, int index) {
    if (tree.isLeaf()) {
        return index;
    }
    out.print("  " + index + ':');
    SimpleMatrix vector = RNNCoreAnnotations.getPredictions(tree);
    for (int i = 0; i < vector.getNumElements(); ++i) {
        out.print("  " + NF.format(vector.get(i)));
    }
    out.println();
    index++;
    for (Tree child : tree.children()) {
        index = outputTreeScores(out, child, index);
    }
    return index;
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Tree(edu.stanford.nlp.trees.Tree)

Example 72 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project CoreNLP by stanfordnlp.

the class SentimentPipeline method outputTreeVectors.

/**
 * Outputs the vectors from the tree.  Counts the tree nodes the
 * same as setIndexLabels.
 */
private static int outputTreeVectors(PrintStream out, Tree tree, int index) {
    if (tree.isLeaf()) {
        return index;
    }
    out.print("  " + index + ':');
    SimpleMatrix vector = RNNCoreAnnotations.getNodeVector(tree);
    for (int i = 0; i < vector.getNumElements(); ++i) {
        out.print("  " + NF.format(vector.get(i)));
    }
    out.println();
    index++;
    for (Tree child : tree.children()) {
        index = outputTreeVectors(out, child, index);
    }
    return index;
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Tree(edu.stanford.nlp.trees.Tree)

Example 73 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project CoreNLP by stanfordnlp.

the class NeuralUtilsTest method testIsZero.

@Test
public void testIsZero() {
    double[][] values = new double[][] { { 0.1, 0.2, 0.3, 0.4, 0.5 }, { 0.0, 0.0, 0.0, 0.0, 0.0 } };
    SimpleMatrix vector1 = new SimpleMatrix(values);
    assertFalse(NeuralUtils.isZero(vector1));
    values = new double[][] { { 0.0, 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0, 0.0 } };
    vector1 = new SimpleMatrix(values);
    assertTrue(NeuralUtils.isZero(vector1));
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Test(org.junit.Test)

Example 74 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.

the class RectifyFundamental method computeG.

private SimpleMatrix computeG(Point3D_F64 epipole, int x0, int y0) {
    double x = epipole.x / epipole.z - x0;
    double y = epipole.y / epipole.z - y0;
    double f = Math.sqrt(x * x + y * y);
    SimpleMatrix G = SimpleMatrix.identity(3);
    G.set(2, 0, -1.0 / f);
    return G;
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix)

Example 75 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.

the class RectifyFundamental method computeAffineH.

/**
 * Finds the values of a,b,c which minimize
 *
 * sum (a*x(+)_i + b*y(+)_i + c - x(-)_i)^2
 *
 * See page 306
 *
 * @return Affine transform
 */
private SimpleMatrix computeAffineH(List<AssociatedPair> observations, DMatrixRMaj H, DMatrixRMaj Hzero) {
    SimpleMatrix A = new SimpleMatrix(observations.size(), 3);
    SimpleMatrix b = new SimpleMatrix(A.numRows(), 1);
    Point2D_F64 c = new Point2D_F64();
    Point2D_F64 k = new Point2D_F64();
    for (int i = 0; i < observations.size(); i++) {
        AssociatedPair a = observations.get(i);
        GeometryMath_F64.mult(Hzero, a.p1, k);
        GeometryMath_F64.mult(H, a.p2, c);
        A.setRow(i, 0, k.x, k.y, 1);
        b.set(i, 0, c.x);
    }
    SimpleMatrix x = A.solve(b);
    SimpleMatrix Ha = SimpleMatrix.identity(3);
    Ha.setRow(0, 0, x.getDDRM().data);
    return Ha;
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) SimpleMatrix(org.ejml.simple.SimpleMatrix) Point2D_F64(georegression.struct.point.Point2D_F64)

Aggregations

SimpleMatrix (org.ejml.simple.SimpleMatrix)156 Test (org.junit.Test)30 Layer (org.gitia.froog.layer.Layer)14 Test (org.junit.jupiter.api.Test)13 Map (java.util.Map)12 ArrayList (java.util.ArrayList)11 TransferFunction (org.gitia.froog.transferfunction.TransferFunction)10 Tree (edu.stanford.nlp.trees.Tree)9 TwoDimensionalMap (edu.stanford.nlp.util.TwoDimensionalMap)9 List (java.util.List)8 LexicalizedParser (edu.stanford.nlp.parser.lexparser.LexicalizedParser)7 Pair (edu.stanford.nlp.util.Pair)6 EmbeddingExtractor (edu.stanford.nlp.coref.neural.EmbeddingExtractor)5 Embedding (edu.stanford.nlp.neural.Embedding)5 DeepTree (edu.stanford.nlp.trees.DeepTree)5 CoreLabel (edu.stanford.nlp.ling.CoreLabel)4 SimpleTensor (edu.stanford.nlp.neural.SimpleTensor)4 DVModel (edu.stanford.nlp.parser.dvparser.DVModel)4 Logsig (org.gitia.froog.transferfunction.Logsig)4 Ignore (org.junit.Ignore)4