按照官方给出的例程一步步跑,前面都没有错,直到跑整个测试集时,程序跑死,后来发现可能是GPU内存不足,可以分批进行测试。再跑程序是可以吧for i in range(100)改小一点,快速跑完,看测试能不能出。
以下是TensorSense博主的代码,原文地址
accuracy_sum = tf.reduce_sum(tf.cast(correct_prediction, tf.float32))
good = 0
total = 0
for i in range(2):
testSet = mnist.test.next_batch(100)
if i ==1 : print(testSet[0].shape[0])
good += accuracy_sum.eval(feed_dict = { x: testSet[0], y_: testSet[1], keep_prob: 1.0})
total += testSet[0].shape[0] # testSet[0].shape[0] 是本batch有的样本数量
print("test accuracy %g"%(good/total))
如果对你有所帮助,谢谢您的鼓励^_^
红包还不收?