我正在关注 MNIST Softmax 教程 https://www.tensorflow.org/tutorials/mnist/beginners/
后面是文档,模型应该是
y = tf.nn.softmax(tf.matmul(x, W) + b)
但在示例源代码中,如您所见
# Create the model
x = tf.placeholder(tf.float32, [None, 784])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
y = tf.matmul(x, W) + b
未使用softmax。我认为需要改变
y = tf.nn.softmax(tf.matmul(x, W) + b)
我假设,在测试函数中它使用argmax,因此不需要将其标准化为0~1.0值。但它会给开发者带来一些困惑。
对此有何想法?
最佳答案
使用 Softmax,第 57 行:
# So here we use tf.nn.softmax_cross_entropy_with_logits on the raw
# outputs of 'y', and then average across the batch.
cross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(y, y_))
参见softmax_cross_entropy_with_logits了解更多详情。
关于tensorflow - 在tensorflow MNIST softmax教程中,没有使用softmax函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41340879/