【问题标题】:What's the mean of tf.nn.softmax in cnncnn中的tf.nn.softmax是什么意思
【发布时间】:2021-07-08 13:40:54
【问题描述】:

我用网上的一些教程实现了一个CNN用于图像分类,找到了softmax的这个功能,没看懂

score = tf.nn.softmax(predictions[0])

当我使用它时,我发现我不理解它们的含义的值

谁能解释一下这个功能,它的用途是什么!

【问题讨论】:

标签: tensorflow conv-neural-network prediction softmax


【解决方案1】:

一个softmax函数可以将你的logits映射到一个百分比,通常用于多类分类问题,百分比总和为1

函数可以这样计算

e.g [1. 0. 1.] -> [0.3, 0.4, 0.3]
softmax = tf.exp(logits) / tf.reduce_sum(tf.exp(logits), axis) # Took from the official tensorflow site

典型用法

import tensorflow as tf

logits = model(data) # make a forward pass(prediction)
predictions = tf.nn.softmax(logits) # so we know the score of our predictions
print(predictions.max())

【讨论】:

    猜你喜欢
    • 2018-07-05
    • 1970-01-01
    • 2011-08-12
    • 2017-06-11
    • 2018-03-05
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 2010-09-29
    相关资源
    最近更新 更多