我正在试用 TensorFlow 教程,但不明白这一行中的 next_batch 是从哪里来的?
batch_xs, batch_ys = mnist.train.next_batch(100)
我在看
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
也没有在那里看到 next_batch。
现在,在我自己的代码中尝试 next_batch 时,我得到了
AttributeError: 'numpy.ndarray' object has no attribute 'next_batch'
所以我想了解 next_batch 是从哪里来的?
原文由 Dan 发布,翻译遵循 CC BY-SA 4.0 许可协议
next_batch
是DataSet
类的一种方法(见 https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/learn/python/learn/datasets/ mnist.py 以获取有关课程内容的更多信息)。当您加载 mnist 数据并将其分配给变量
mnist
时:查看
mnist.train
的类。您可以通过键入以下内容来查看它:您会看到以下内容:
因为
mnist.train
是类DataSet
的一个实例,你可以使用类的函数next_batch
。有关类的更多信息,请查看 文档。