将 sigmoid 结果解释为神经网络中的概率 [英] Interpreting a sigmoid result as probability in neural networks

查看:17
本文介绍了将 sigmoid 结果解释为神经网络中的概率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在最后一层创建了一个带有 sigmoid 激活函数的神经网络,所以我得到的结果介于 0 和 1 之间.我想将事物分为 2 类,所以我检查是数字 > 0.5,然后分类1 其他类 0".都是基本的.但是,我想说它在 0 类中的概率是 x,而在 1 类中是 y".

I've created a neural network with a sigmoid activation function in the last layer, so I get results between 0 and 1. I want to classify things in 2 classes, so I check "is the number > 0.5, then class 1 else class 0". All basic. However, I would like to say "the probability of it being in class 0 is x and in class 1 is y".

我该怎么做?

  • 像 0.73 这样的数字是否告诉我 73% 的确定属于第 1 类?然后 1-0.73 = 0.27 所以在第 0 类中有 27%?
  • 当它是 0.27 时,是否意味着它在第 0 类中有 27% 的把握,在第 1 类中有 73% 的把握?毫无意义.

我是否应该使用 0.5 并查看数字离中心多远,然后就是百分比"?

Should I work with the 0.5 and look "how far away from the center is the number, and then that's the percentage"?

还是我误解了神经网络的结果?

Or am I misunderstanding the result of the NN?

推荐答案

正如 Teja 所指出的,简短的回答是否定的,但是,根据您使用的损失,它可能比您想象的更接近真相.

As pointed out by Teja, the short answer is no, however, depending on the loss you use, it may be closer to truth than you may think.

想象一下,您尝试训练您的网络将数字区分为 beautifulugly 两个任意类别.假设您输入的数字是 01 并且 00.2 被标记为 的概率丑陋1s 有0.6成为丑陋的概率.

Imagine you try to train your network to differentiate numbers into two arbitrary categories that are beautiful and ugly. Say your input number are either 0 or 1 and 0s have a 0.2 probability of being labelled ugly whereas 1s have o 0.6probability of being ugly.

想象一下,您的神经网络将 0s 和 1s 作为输入,将它们传递到一些层,并以 softmax 函数结束.如果您的损失是二元交叉熵,那么您的网络的最佳解决方案是当它在输入中看到 00 时输出 0.2code>0.6 当它在输入中看到 1 (这是交叉熵的一个属性,当您输出每个标签的真实概率时,它会被最小化).因此,您可以将这些数字解释为概率.

Imagine that your neural network takes as inputs 0s and 1s, passes them into some layers, and ends in a softmax function. If your loss is binary cross-entropy, then the optimal solution for your network is to output 0.2 when it sees a 0 in input and 0.6 when it sees a 1 in input (this is a property of the cross-entropy which is minimized when you output the true probabilities of each label). Therefore, you can interpret these numbers as probabilities.

当然,现实世界的例子并不那么容易,而且通常是确定性的,所以解释有点棘手.但是,我认为,只要将交叉熵用作损失,就可以将结果视为概率并不完全错误.

Of course, real world examples are not that easy and are generally deterministic so the interpretation is a little bit tricky. However, I believe that it is not entirely false to think of your results as probabilities as long as you use the cross-entropy as a loss.

对不起,这个答案不是非黑即白,但现实有时很复杂;)

I'm sorry, this answer is not black or white, but reality is sometimes complex ;)

这篇关于将 sigmoid 结果解释为神经网络中的概率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆