Search in sources :

Example 11 with Evaluation

use of org.deeplearning4j.eval.Evaluation in project deeplearning4j by deeplearning4j.

the class GravesLSTMOutputTest method eval.

private Evaluation eval(MultiLayerNetwork network) {
    Evaluation ev = new Evaluation(nIn);
    INDArray predict = network.output(reshapeInput(data));
    ev.eval(data, predict);
    log.info(ev.stats());
    return ev;
}
Also used : Evaluation(org.deeplearning4j.eval.Evaluation) INDArray(org.nd4j.linalg.api.ndarray.INDArray)

Example 12 with Evaluation

use of org.deeplearning4j.eval.Evaluation in project deeplearning4j by deeplearning4j.

the class GravesLSTMOutputTest method testSameLabelsOutputWithTBPTT.

@Test
public void testSameLabelsOutputWithTBPTT() {
    MultiLayerNetwork network = new MultiLayerNetwork(getNetworkConf(40, true));
    network.init();
    network.setListeners(new ScoreIterationListener(1));
    for (int i = 0; i < window / 100; i++) {
        INDArray d = data.get(NDArrayIndex.interval(100 * i, 100 * (i + 1)), NDArrayIndex.all());
        network.fit(reshapeInput(d.dup()), reshapeInput(d.dup()));
    }
    Evaluation ev = eval(network);
}
Also used : Evaluation(org.deeplearning4j.eval.Evaluation) INDArray(org.nd4j.linalg.api.ndarray.INDArray) ScoreIterationListener(org.deeplearning4j.optimize.listeners.ScoreIterationListener) Test(org.junit.Test)

Example 13 with Evaluation

use of org.deeplearning4j.eval.Evaluation in project deeplearning4j by deeplearning4j.

the class BaseOutputLayer method f1Score.

/**
     * Returns the f1 score for the given examples.
     * Think of this to be like a percentage right.
     * The higher the number the more it got right.
     * This is on a scale from 0 to 1.
     *
     * @param examples te the examples to classify (one example in each row)
     * @param labels   the true labels
     * @return the scores for each ndarray
     */
@Override
public double f1Score(INDArray examples, INDArray labels) {
    Evaluation eval = new Evaluation();
    eval.eval(labels, labelProbabilities(examples));
    return eval.f1();
}
Also used : Evaluation(org.deeplearning4j.eval.Evaluation)

Example 14 with Evaluation

use of org.deeplearning4j.eval.Evaluation in project deeplearning4j by deeplearning4j.

the class LossLayer method f1Score.

/**
     * Returns the f1 score for the given examples.
     * Think of this to be like a percentage right.
     * The higher the number the more it got right.
     * This is on a scale from 0 to 1.
     *
     * @param examples te the examples to classify (one example in each row)
     * @param labels   the true labels
     * @return the scores for each ndarray
     */
@Override
public double f1Score(INDArray examples, INDArray labels) {
    Evaluation eval = new Evaluation();
    eval.eval(labels, labelProbabilities(examples));
    return eval.f1();
}
Also used : Evaluation(org.deeplearning4j.eval.Evaluation)

Example 15 with Evaluation

use of org.deeplearning4j.eval.Evaluation in project deeplearning4j by deeplearning4j.

the class TestSparkLayer method testIris2.

@Test
public void testIris2() throws Exception {
    NeuralNetConfiguration conf = new NeuralNetConfiguration.Builder().optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).iterations(10).learningRate(1e-1).layer(new org.deeplearning4j.nn.conf.layers.OutputLayer.Builder(LossFunctions.LossFunction.MCXENT).nIn(4).nOut(3).weightInit(WeightInit.XAVIER).activation(Activation.SOFTMAX).build()).build();
    System.out.println("Initializing network");
    SparkDl4jLayer master = new SparkDl4jLayer(sc, conf);
    DataSet d = new IrisDataSetIterator(150, 150).next();
    d.normalizeZeroMeanZeroUnitVariance();
    d.shuffle();
    List<DataSet> next = d.asList();
    JavaRDD<DataSet> data = sc.parallelize(next);
    OutputLayer network2 = (OutputLayer) master.fitDataSet(data);
    Evaluation evaluation = new Evaluation();
    evaluation.eval(d.getLabels(), network2.output(d.getFeatureMatrix()));
    System.out.println(evaluation.stats());
}
Also used : OutputLayer(org.deeplearning4j.nn.layers.OutputLayer) Evaluation(org.deeplearning4j.eval.Evaluation) IrisDataSetIterator(org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator) DataSet(org.nd4j.linalg.dataset.DataSet) NeuralNetConfiguration(org.deeplearning4j.nn.conf.NeuralNetConfiguration) Test(org.junit.Test) BaseSparkTest(org.deeplearning4j.spark.BaseSparkTest)

Aggregations

Evaluation (org.deeplearning4j.eval.Evaluation)30 Test (org.junit.Test)24 INDArray (org.nd4j.linalg.api.ndarray.INDArray)23 DataSet (org.nd4j.linalg.dataset.DataSet)22 MultiLayerNetwork (org.deeplearning4j.nn.multilayer.MultiLayerNetwork)18 DataSetIterator (org.nd4j.linalg.dataset.api.iterator.DataSetIterator)15 ScoreIterationListener (org.deeplearning4j.optimize.listeners.ScoreIterationListener)12 MultiLayerConfiguration (org.deeplearning4j.nn.conf.MultiLayerConfiguration)11 MnistDataSetIterator (org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator)10 NeuralNetConfiguration (org.deeplearning4j.nn.conf.NeuralNetConfiguration)10 IrisDataSetIterator (org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator)9 SplitTestAndTrain (org.nd4j.linalg.dataset.SplitTestAndTrain)7 LFWDataSetIterator (org.deeplearning4j.datasets.iterator.impl.LFWDataSetIterator)5 ConvolutionLayerSetup (org.deeplearning4j.nn.conf.layers.setup.ConvolutionLayerSetup)4 IterationListener (org.deeplearning4j.optimize.api.IterationListener)4 BaseSparkTest (org.deeplearning4j.spark.BaseSparkTest)4 ConvolutionLayer (org.deeplearning4j.nn.conf.layers.ConvolutionLayer)3 DenseLayer (org.deeplearning4j.nn.conf.layers.DenseLayer)3 RnnOutputLayer (org.deeplearning4j.nn.layers.recurrent.RnnOutputLayer)3 SparkDl4jMultiLayer (org.deeplearning4j.spark.impl.multilayer.SparkDl4jMultiLayer)3