【发布时间】:2018-06-19 16:33:31
【问题描述】:
在 TensorFlow 的 CNN MNIST 示例中,我不明白批量大小是如何工作的,当他们调用模型时,他们将 bach 的大小指定为 100:
train_input_fn = tf.estimator.inputs.numpy_input_fn(
x={"x": train_data},
y=train_labels,
batch_size=100,
num_epochs=None,shuffle=True)
mnist_classifier.train(input_fn=train_input_fn,steps=20000,hooks=[logging_hook])
但是当模型被调用时:
def cnn_model_fn(features, labels, mode):
# Input Layer
# Reshape X to 4-D tensor: [batch_size, width, height, channels]
# MNIST images are 28x28 pixels, and have one color channel
input_layer = tf.reshape(features["x"], [-1, 28, 28, 1])
他们将 -1 放入批量大小,我在 tensorflow 教程中阅读,当他们告诉计算机推断该维度时,他们使用了 -1 我不明白的是,在我们放入 100 之前,现在因为 -1 不明白你能帮我解释一下如何输入模型的批量大小吗?谢谢。
【问题讨论】:
标签: tensorflow batch-processing mnist convolutional-neural-network tensorflow-estimator