这是我解决此问题的方法:错误表示在准确性评估期间GPU内存不足。因此,它需要一个较小的数据集,可以通过批量使用数据来实现。因此,与其在整个测试数据集上运行代码,不如在本文中提到的那样需要分批运行: 使用TensorFlow时如何分批读取数据
因此,为了对测试数据集进行准确性评估,而不是以下位置:
print("test accuracy %g"%accuracy.eval(feed_dict={ x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0}))
可以使用:
for i in xrange(10):
testSet = mnist.test.next_batch(50)
print("test accuracy %g"%accuracy.eval(feed_dict={ x: testSet[0], y_: testSet[1], keep_prob: 1.0}))
当我运行1000 epochs
进行training
并使用10 batches
的batch_size = 50
进行accuracy evaluation
,我得到以下结果:
step 0, training accuracy 0.04
step 100, training accuracy 0.88
step 200, training accuracy 0.9
step 300, training accuracy 0.88
step 400, training accuracy 0.94
step 500, training accuracy 0.96
step 600, training accuracy 0.94
step 700, training accuracy 0.96
step 800, training accuracy 0.9
step 900, training accuracy 1
test accuracy 1
test accuracy 0.92
test accuracy 1
test accuracy 1
test accuracy 0.94
test accuracy 0.96
test accuracy 0.92
test accuracy 0.96
test accuracy 0.92
test accuracy 0.94
0
这是我正在运行的示例MNIST代码:
我正在使用的GPU是:
GeForce GTX 750 Ti
错误:
我读了一些与同一个问题相关的github问题( 在这里 , 这里 ),但是不明白我应该如何更改代码来解决这个问题。