【发布时间】:2019-07-03 11:44:26
【问题描述】:
我的代码与tensorflow 2.0 tutorial 具有相似的模式。 我希望我的数据集对象在每个时期都重新洗牌。
dataset = tf.data.Dataset.from_tensor_slices(['a','b','c','d'])
dataset = dataset.shuffle(100)
for epoch in range(10):
for d in dataset:
print(d)
结果:
tf.Tensor(b'c', shape=(), dtype=string)
tf.Tensor(b'a', shape=(), dtype=string)
tf.Tensor(b'b', shape=(), dtype=string)
tf.Tensor(b'd', shape=(), dtype=string)
tf.Tensor(b'c', shape=(), dtype=string)
tf.Tensor(b'a', shape=(), dtype=string)
tf.Tensor(b'b', shape=(), dtype=string)
tf.Tensor(b'd', shape=(), dtype=string)
...
似乎数据集并没有为每个时期洗牌。 我应该为每个 epoch 调用 .shuffle() 吗?
【问题讨论】:
标签: tensorflow tensorflow-datasets tensorflow2.0