Tensorflow Deep MNIST: Resource exhausted: OOM when allocating tensor with shape[10000,32,28,28]

后端 未结 2 1694
失恋的感觉
失恋的感觉 2020-12-13 15:02

This is the sample MNIST code I am running:

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets(\'MNIST_data\', one_         


        
2条回答
  •  醉话见心
    2020-12-13 15:29

    Complementing Abhijay's answer, you can easily get the mean accuracy accross the test minibatches

    accuracy_sum = tf.reduce_sum(tf.cast(correct_prediction, tf.float32))
    good = 0
    total = 0
    for i in xrange(10):
        testSet = mnist.test.next_batch(50)
        good += accuracy_sum.eval(feed_dict={ x: testSet[0], y_: testSet[1], keep_prob: 1.0})
        total += testSet[0].shape[0]
    print("test accuracy %g"%(good/total))
    

提交回复
热议问题