Python Deep MNIST教程无法打印测试精度,且没有错误消息

Python Deep MNIST教程无法打印测试精度,且没有错误消息,python,tensorflow,Python,Tensorflow,我尝试在我的计算机上运行deep MNIST教程代码(),但当试图打印出测试精度时,它退出。我所做的唯一更改是将迭代次数更改为100次,并将打印频率更改为每10次迭代一次,如下所示: Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32 第159行: for i in range(20000): 变成 for i in range(100): if i %

我尝试在我的计算机上运行deep MNIST教程代码(),但当试图打印出测试精度时,它退出。我所做的唯一更改是将迭代次数更改为100次,并将打印频率更改为每10次迭代一次,如下所示:

Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
第159行:

for i in range(20000):  
变成

for i in range(100):  
if i % 10 == 0:  
第161行:

if i % 100 == 0:  
变成

for i in range(100):  
if i % 10 == 0:  
这是它的输出(在cmd中运行):

请注意,一旦完成训练,脚本将自动退出,不会出现错误,而不会打印测试精度,即使我提供了-I标记。当我删除打印测试精度的行(第167行和第168行)时

然后脚本就完美地工作了。因此,这行代码似乎以某种方式导致脚本退出

我试过运行softmax教程(),它还使用相同的数据集打印测试精度

print(accuracy.eval(feed_dict = {x: mnist.test.images, y_: mnist.test.labels}))
而且效果很好:

C:\Users\Steven\Documents\Atom\tensorflow-tutorial>python -i mnist_softmax_tutor
ial.py
Extracting MNIST_data\train-images-idx3-ubyte.gz
Extracting MNIST_data\train-labels-idx1-ubyte.gz
Extracting MNIST_data\t10k-images-idx3-ubyte.gz
Extracting MNIST_data\t10k-labels-idx1-ubyte.gz
2018-01-18 21:49:34.174464: I C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\
36\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instruct
ions that this TensorFlow binary was not compiled to use: AVX
0.9143
>>> exit()

C:\Users\Steven\Documents\Atom\tensorflow-tutorial>
我看了另一篇带有类似错误()的帖子,上面说运行Windows安装验证脚本()。但是,我运行了它,没有发现任何问题:

C:\Users\Steven\Documents\Atom\tensorflow-tutorial>python tensorflow_self_check.
py
TensorFlow successfully installed.
The installed version of TensorFlow does not include GPU support.
我还尝试重新安装TensorFlow(使用pip卸载,然后使用pip安装),但这并没有解决问题

我的python版本如下:

Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
我使用

pip3 install --upgrade tensorflow

感谢您的帮助。谢谢

我的系统正在工作,你能再检查一下吗

Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Extracting /tmp/tensorflow/mnist/input_data/train-images-idx3-ubyte.gz
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Extracting /tmp/tensorflow/mnist/input_data/train-labels-idx1-ubyte.gz
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Extracting /tmp/tensorflow/mnist/input_data/t10k-images-idx3-ubyte.gz
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting /tmp/tensorflow/mnist/input_data/t10k-labels-idx1-ubyte.gz
Saving graph to: /tmp/tmpaxAoQ2
2018-01-19 17:02:14.087095: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
step 0, training accuracy 0.06
test accuracy 0.4421

原来问题是我的计算机没有足够的RAM来测试所有10000个测试图像。通常,有些东西会抛出一个记忆错误,但我想张量流会抑制这个错误

>>> with sess.as_default(): print(accuracy.eval(feed_dict = {x: mnist.test.image
s[:1000,:], y_: mnist.test.labels[:1000,:], keep_prob: 1.0}))
...
0.442
>>> with sess.as_default(): print(accuracy.eval(feed_dict = {x: mnist.test.image
s[:10000,:], y_: mnist.test.labels[:10000,:], keep_prob: 1.0}))
...

C:\Users\Steven\Documents\Atom\tensorflow-tutorial>

在第二行中,Python在放弃和退出之前会释放高达2gb的ram。不确定错误消息被抑制的原因。

可能是字符串格式有问题,如您在softmax教程中尝试过不使用格式打印吗?谢谢您的建议。我将打印行更改为
print(accurity.eval(feed\u dict={x:mnist.test.images,y\u:mnist.test.labels,keep\u prob:1.0}))
,但行为没有改变。感谢您的建议,但我不确定“再次检查”是什么意思。我尝试了一次又一次,但没有效果(如上所述)。我想再试一次,该代码正在我的系统上运行,它正在打印测试精度,正如您在上面看到的。您能告诉我您使用的是哪个版本的tensorflow吗?
tf.\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu