I'm new to dL4J and keep running across this issue;
java.lang.IllegalArgumentException: occurrences cannot be negative: -11668
And I really can't seem to workout why. I've checked my testData labels and the model output and there are definitely no negative numbers.
I can provide the model output and testdata output if need be but it's pretty long.
This is the Evaluate method.
private Evaluation evaluate (MultiLayerNetwork model, DataSet testData){;
INDArray output = model.output(testData.getFeatures());
System.out.println("Labels: " + testData.getLabels());
System.out.println("Output: " + output);
Evaluation eval = new Evaluation();
eval.eval(testData.getLabels(), output); // <-- Issue here, flipping the two around gives diff results.
return eval;
}
Model:
public MultiLayerConfiguration getMultiLayerConfiguration() {
return new NeuralNetConfiguration.Builder()
.seed(123)
.updater(new Adam())
.list()
.layer(new DenseLayer.Builder()
.nIn(3)
.nOut(50)
.activation(Activation.RELU)
.build())
.layer(new DenseLayer.Builder()
.nIn(50)
.nOut(100)
.activation(Activation.RELU)
.build())
.layer(new DenseLayer.Builder()
.nIn(100)
.nOut(50)
.activation(Activation.RELU)
.build())
.layer(new OutputLayer.Builder()
.nIn(50)
.nOut(1)
.lossFunction(LossFunctions.LossFunction.MSE)
.activation(Activation.IDENTITY)
.build())
.build();
}
As a last ditch attempt, I've tried to flip the output and testData.getLabels() but this is just giving me a different negative result. I've also amended my model multiple times but this exception is persisting.
Any help will be much appreciated.
It looks like you're trying to use a confusion matrix for evaluation. Dl4j doesn't know what your objective is so you have to specify it. In this case you're doing regression.
Confusion matrices are not used with regression just classification. Use the RegressionEvaluation class for your data instead and you should be fine.
Please consider looking at our examples: https://github.com/deeplearning4j/deeplearning4j-examples - this covers a lot of use cases.