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;
}
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);
}
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();
}
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();
}
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());
}
Aggregations