我正在阅读tensorflow教程(https://www.tensorflow.org/get_started/mnist/pros)
具体来说:
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(20000):
batch = mnist.train.next_batch(50)
if i % 100 == 0:
train_accuracy = accuracy.eval(feed_dict={
x: batch[0], y_: batch[1], keep_prob: 1.0})
print('step %d, training accuracy %g' % (i, train_accuracy))
train_step.run(feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5})
到目前为止,一切都完美无缺。它完成了20,000步培训。但后来我达到了这一点:
print('test accuracy %g' % accuracy.eval(feed_dict={
x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0}))
发生了这种情况:
>>> print('test accuracy %g' % accuracy.eval(feed_dict={
File "<stdin>", line 1
print('test accuracy %g' % accuracy.eval(feed_dict={
^
IndentationError: unexpected indent
>>> x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0}))
File "<stdin>", line 1
x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0}))
现在,如果我尝试更改间距,并从for循环中单独打印最终精度,我会得到更令人不愉快的东西:
print('test accuracy %g' % accuracy.eval(feed_dict={
... x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0}))
Traceback (most recent call last):
...
tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value Variable_12
不确定发生了什么。任何建议或反馈将不胜感激。
谢谢