Java Code Examples for org.deeplearning4j.nn.graph.ComputationGraph#evaluateRegression()
The following examples show how to use
org.deeplearning4j.nn.graph.ComputationGraph#evaluateRegression() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegressionEvalTest.java From deeplearning4j with Apache License 2.0 | 4 votes |
@Test public void testRegressionEvalMethods() { //Basic sanity check MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().weightInit(WeightInit.ZERO).list() .layer(0, new OutputLayer.Builder().activation(Activation.TANH) .lossFunction(LossFunctions.LossFunction.MSE).nIn(10).nOut(5).build()) .build(); MultiLayerNetwork net = new MultiLayerNetwork(conf); net.init(); INDArray f = Nd4j.zeros(4, 10); INDArray l = Nd4j.ones(4, 5); DataSet ds = new DataSet(f, l); DataSetIterator iter = new ExistingDataSetIterator(Collections.singletonList(ds)); org.nd4j.evaluation.regression.RegressionEvaluation re = net.evaluateRegression(iter); for (int i = 0; i < 5; i++) { assertEquals(1.0, re.meanSquaredError(i), 1e-6); assertEquals(1.0, re.meanAbsoluteError(i), 1e-6); } ComputationGraphConfiguration graphConf = new NeuralNetConfiguration.Builder().weightInit(WeightInit.ZERO).graphBuilder() .addInputs("in").addLayer("0", new OutputLayer.Builder() .lossFunction(LossFunctions.LossFunction.MSE) .activation(Activation.TANH).nIn(10).nOut(5).build(), "in") .setOutputs("0").build(); ComputationGraph cg = new ComputationGraph(graphConf); cg.init(); RegressionEvaluation re2 = cg.evaluateRegression(iter); for (int i = 0; i < 5; i++) { assertEquals(1.0, re2.meanSquaredError(i), 1e-6); assertEquals(1.0, re2.meanAbsoluteError(i), 1e-6); } }
Example 2
Source File: RegressionScoreFunction.java From deeplearning4j with Apache License 2.0 | 4 votes |
@Override public double score(ComputationGraph graph, DataSetIterator iterator) { RegressionEvaluation e = graph.evaluateRegression(iterator); return e.scoreForMetric(metric); }
Example 3
Source File: RegressionScoreFunction.java From deeplearning4j with Apache License 2.0 | 4 votes |
@Override public double score(ComputationGraph graph, MultiDataSetIterator iterator) { RegressionEvaluation e = graph.evaluateRegression(iterator); return e.scoreForMetric(metric); }
Example 4
Source File: TestSetRegressionScoreFunction.java From deeplearning4j with Apache License 2.0 | 4 votes |
@Override public double score(ComputationGraph graph, DataSetIterator iterator) { RegressionEvaluation e = graph.evaluateRegression(iterator); return ScoreUtil.getScoreFromRegressionEval(e, regressionValue); }
Example 5
Source File: TestSetRegressionScoreFunction.java From deeplearning4j with Apache License 2.0 | 4 votes |
@Override public double score(ComputationGraph graph, MultiDataSetIterator iterator) { RegressionEvaluation e = graph.evaluateRegression(iterator); return ScoreUtil.getScoreFromRegressionEval(e, regressionValue); }
Example 6
Source File: ScoreUtil.java From deeplearning4j with Apache License 2.0 | 2 votes |
/** * Run a {@link RegressionEvaluation} * over a {@link DataSetIterator} * @param model the model to use * @param testSet the test set iterator * @param regressionValue the regression type to use * @return */ public static double score(ComputationGraph model, DataSetIterator testSet, RegressionValue regressionValue) { RegressionEvaluation evaluation = model.evaluateRegression(testSet); return getScoreFromRegressionEval(evaluation, regressionValue); }