2016-12-27 91 views
2

IM以下MNIST使用SoftMax教程https://www.tensorflow.org/tutorials/mnist/beginners/在tensorflow MNIST SOFTMAX教程,SOFTMAX函數時使用

其次是文檔,該模型應當是

y = tf.nn.softmax(tf.matmul(x, W) + b) 

但在樣本源代碼,U可以見

# 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的值。但它可能會給開發人員帶來一些困惑。

作爲這個想法?

回答

2

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

相關問題