代码拉取完成,页面将自动刷新
tf.data.Dataset.shuffle(
buffer_size,
seed=None,
reshuffle_each_iteration=None
)
For more information, see tf.data.Dataset.shuffle.
mindspore.dataset.GeneratorDataset.shuffle(
buffer_size
)
For more information, see mindspore.dataset.GeneratorDataset.shuffle.
TensorFlow: Randomly shuffle the data in the pipeline. It supports setting a random seed and whether to reshuffle at each iteration.
MindSpore: Randomly shuffle the data in the pipeline. The global random seed can be set through mindspore.dataset.config.set_seed
, and it will reshuffe every iteration.
# The following implements shuffle with MindSpore.
import numpy as np
import mindspore.dataset as ds
ds.config.set_seed(57)
data = np.array([[1, 2], [3, 4], [5, 6]])
dataset = ds.NumpySlicesDataset(data=data, column_names=["data"], shuffle=False)
dataset = dataset.shuffle(2)
for item in dataset.create_dict_iterator():
print(item["data"])
# [1 2]
# [5 6]
# [3 4]
# The following implements shuffle with TensorFlow.
import tensorflow as tf
tf.compat.v1.enable_eager_execution()
data = tf.constant([[1, 2], [3, 4], [5, 6]])
dataset = tf.data.Dataset.from_tensor_slices(data)
dataset = dataset.shuffle(2, seed=57)
for value in dataset.take(3):
print(value)
# [3 4]
# [5 6]
# [1 2]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。