簡體   English   中英

使DL4J分類器返回得分

[英]Make DL4J classifier return score

我正在玩DeepLearning4J ,我想知道如何讓分類器返回分數而不是標簽。 假設我使用線性分類器教程中的代碼,我想讓ANN返回給定訓練示例的概率標記為0或1.當前配置如下所示:

MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
        .seed(123)
        .iterations(1)
        .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
        .learningRate(0.01)
        .updater(Updater.NESTEROVS)
        .momentum(0.9)
        .list()
        .layer(0, new DenseLayer.Builder()
                .nIn(2)
                .nOut(20)
                .weightInit(WeightInit.XAVIER)
                .activation(Activation.RELU)
                .build())
        .layer(1, new OutputLayer.Builder(LossFunction.NEGATIVELOGLIKELIHOOD)
                .nIn(20)
                .nOut(2)
                .weightInit(WeightInit.XAVIER)
                .activation(Activation.SOFTMAX)
                .build())
        .pretrain(false)
        .backprop(true)
        .build();

使用model.output。

你會得到一個ndarray( http://nd4j.org/tensor

它在輸出上使用softmax,這意味着您可以獲得批量大小x標簽輸出。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM