Machine learning Tensorflow-如何将MNIST数据集与完整批处理一起使用?

Machine learning Tensorflow-如何将MNIST数据集与完整批处理一起使用?,machine-learning,tensorflow,mini-batch,Machine Learning,Tensorflow,Mini Batch,我在学习机器学习。在我学习的过程中,我使用MNIST数据集找到了Tensorflow CNN代码。下面是我想知道的代码 cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y_conv), reduction_indices=[1])) train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy) correct_prediction = tf.equal(tf.

我在学习机器学习。在我学习的过程中,我使用MNIST数据集找到了Tensorflow CNN代码。下面是我想知道的代码

cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y_conv), reduction_indices=[1]))
train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)
correct_prediction = tf.equal(tf.argmax(y_conv,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
sess.run(tf.global_variables_initializer())

for i in range(1000):
  batch = mnist.train.next_batch(100)
   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})

print("test accuracy %g"%accuracy.eval(feed_dict={
     x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0}))
在这段代码中,我的问题是关于batch=mnist.train.next\u batch100。当我搜索这个时,这意味着这是一个小批量,从MNIST数据集中随机选择100个数据。现在是我的问题

当我想用完整的批处理测试这段代码时,我应该怎么做?只需将mnist.train.next\u batch100更改为mnist.train.next\u batch55000?
是的,获得一批55000将在MNIST的所有数字上训练一个历元

请注意,这是一个坏主意:这可能不适合你的记忆。你必须保存55000个数字的重量激活和梯度。。。您的Python很可能会崩溃


通过对一批100幅随机图像进行1000次训练,你会得到一个很好的结果,你的电脑也会很开心

你为什么不试试这个并告诉我们结果呢?我已经试过了,但我不相信这是正确的方法。结果,Python崩溃了。我认为是记忆问题。@rmeertens解释了正确的原因。谢谢,你是对的。当我以完整的批处理方式运行这段代码时,Python崩溃了。哈哈,我只是想知道,这是完整批处理运行代码的正确方法