Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x TensorFlow:dataset.train.next\u批次是如何定义的?_Python 3.x_Tensorflow_Neural Network_Autoencoder - Fatal编程技术网

Python 3.x TensorFlow:dataset.train.next\u批次是如何定义的?

Python 3.x TensorFlow:dataset.train.next\u批次是如何定义的?,python-3.x,tensorflow,neural-network,autoencoder,Python 3.x,Tensorflow,Neural Network,Autoencoder,我正在尝试学习TensorFlow,并在以下位置学习示例: 然后,我在下面的代码中有一些问题: for epoch in range(training_epochs): # Loop over all batches for i in range(total_batch): batch_xs, batch_ys = mnist.train.next_batch(batch_size) # Run optimization op (backprop)

我正在尝试学习TensorFlow,并在以下位置学习示例:

然后,我在下面的代码中有一些问题:

for epoch in range(training_epochs):
    # Loop over all batches
    for i in range(total_batch):
        batch_xs, batch_ys = mnist.train.next_batch(batch_size)
        # Run optimization op (backprop) and cost op (to get loss value)
        _, c = sess.run([optimizer, cost], feed_dict={X: batch_xs})
    # Display logs per epoch step
    if epoch % display_step == 0:
        print("Epoch:", '%04d' % (epoch+1),
              "cost=", "{:.9f}".format(c))
既然mnist只是一个数据集,
mnist.train.next\u batch
的确切含义是什么?如何定义数据集.train.next_批


谢谢

tf.contrib.learn
模块中定义的返回
mnist
对象。实现了
mnist.train.next\u batch(batch\u size)
方法,它返回两个数组的元组,其中第一个数组表示一批
batch\u size
mnist图像,第二个数组表示与这些图像对应的一批
batch size
标签

图像作为大小为
[batch\u size,784]
的二维NumPy数组返回(因为MNIST图像中有784个像素),标签作为大小为
[batch\u size]
的一维NumPy数组返回(如果使用
one\u hot=False
调用了
读取数据集()
)或大小为
的二维NumPy数组返回[batch\u size,10]
(如果使用
one\u hot=True
调用
read\u data\u sets()
)。

值得一提的是,在每个历元遍历所有示例后,会重新排列这些示例。您可以通过
数据集跟踪您在历元中的位置。\u历元中的索引(如
mnist.train\u历元中的索引)