Python 3.x TensorFlow:dataset.train.next\u批次是如何定义的?
我正在尝试学习TensorFlow,并在以下位置学习示例: 然后,我在下面的代码中有一些问题: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)
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历元中的索引)