如何为CNN的每个班级获得0到1的分数?

A. *_*iro 1 classification deep-learning conv-neural-network tensorflow softmax

我目前正在训练一个网络(使用Tensorflow实现的CNN)来分类超过3个类,事情是我最终得分如下:

[ -20145.36, 150069, 578456.3 ].
Run Code Online (Sandbox Code Playgroud)

我希望得分在0到1之间(某种概率).

起初,我想过使用sigmoid函数,但后来我发现这个讨论甚至没有提到:

https://www.quora.com/How-do-you-normalize-numeric-scores-to-a-0-1-range-for-comparing-different-machine-learning-techniques

你建议我做什么,每堂课的得分在0到1之间?

谢谢

kma*_*o23 5

作为最后一层,您总是使用softmax来获得n级分类分数.因此,您在tensorflow分类文档中提到了很多选项.

最简单的是使用tf.nn.softmax()

softmax = exp(logits) / reduce_sum(exp(logits), dim)
Run Code Online (Sandbox Code Playgroud)

例:

In [63]: ar = np.array([ -20145.36, 150069, 578456.3 ])

In [64]: scores = tf.nn.softmax(ar)

In [65]: sess = tf.InteractiveSession()

In [66]: scores.eval()
Out[66]: array([ 0.,  0.,  1.])
Run Code Online (Sandbox Code Playgroud)