【问题标题】:DeepLearning4j - occurrences cannot be negativeDeepLearning4j - 出现次数不能为负
【发布时间】:2023-02-23 06:18:39
【问题描述】:

我是 dL4J 的新手,一直遇到这个问题; java.lang.IllegalArgumentException: occurrences cannot be negative: -11668 而且我似乎真的无法锻炼为什么。我检查了我的 testData 标签和模型输出,肯定没有负数。

如果需要,我可以提供模型输出和测试数据输出,但它很长。

这是评估方法。

    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;
    }

模型:

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

作为最后的尝试,我尝试翻转输出和 testData.getLabels() 但这只是给了我一个不同的负面结果。我也多次修改了我的模型,但这个异常仍然存在。

任何帮助都感激不尽。

【问题讨论】:

    标签: java dl4j


    【解决方案1】:

    看起来您正在尝试使用混淆矩阵进行评估。 Dl4j 不知道您的目标是什么,所以您必须指定它。在这种情况下,您正在进行回归。

    混淆矩阵不用于回归只是分类。 改为对您的数据使用 evalRegression,您应该没问题。

    请考虑查看我们的示例:https://github.com/deeplearning4j/deeplearning4j-examples - 这涵盖了很多用例。

    【讨论】:

      猜你喜欢
      • 2016-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-09
      • 2016-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多