【问题标题】:How do i get the maximum valued label when using a softmax activation function in the output layer of neural network?在神经网络的输出层中使用 softmax 激活函数时如何获得最大值标签?
【发布时间】:2019-06-04 17:57:54
【问题描述】:

在我训练的模型中,我在神经网络的输出层应用了 softmax 函数。输出有 41 个类别,我想获取具有最大值的标签和值本身..i。 e 在输出中。一组输入的 41 种疾病 ....softmax 预测所有疾病,但我想以最大概率打印疾病以及概率我该怎么做?

【问题讨论】:

  • 你能分享你尝试过的东西吗?你有正在编写的示例代码吗?

标签: python-3.x machine-learning neural-network softmax activation-function


【解决方案1】:

您可以通过简单地使用np.argmax() 函数来实现这一点:

例如,要获得您的第一个测试示例的最大概率的疾病指数:

predictions = model.predict(x_test)
print(np.argmax(predictions[0])  #output the index of the disease with max proba
                                 #for example N#0

【讨论】:

    猜你喜欢
    • 2018-03-24
    • 2020-10-09
    • 2019-08-02
    • 2012-04-11
    • 1970-01-01
    • 2018-03-22
    • 2018-07-14
    • 2014-01-18
    • 2017-12-08
    相关资源
    最近更新 更多