为什么MNIST数据集的输入范围应该在0到1之间?

时间:2018-12-07 15:40:55

标签: python mnist

我是MNIST的初学者。 我有几个问题。这是其中之一。

我将MNIST数据集存储在一个csv文件中(范围在0到255之间)

我训练了这些数据,但得到了错误的答案,全为0。

但是当我将数据集的值除以255时,得到了正确的值(范围是0和1之间)

那么,为什么MNIST数据集的输入范围应该在0到1之间?

我使用了MNIST教程中的代码。

x = tf.placeholder(tf.float32, [None, 784])
W = tf.Variable(tf.zeros([784,10]))
b = tf.Variable(tf.zeros([10]))
y = tf.nn.softmax(tf.matmul(x, W) + b)
y_ = tf.placeholder(tf.float32, [None, 10])
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_*tf.log(y),reduction_indices=[1]))
train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy)

0 个答案:

没有答案