【发布时间】:2021-08-14 14:51:41
【问题描述】:
我正在进行从 Tensorflow 1.15 到 2.4.1(python 3.8)的升级项目。以下是我面临的问题。 我知道问题出在 tf.contrib 上。我该如何完成这项工作?
if num_epochs is not None and shuffle:
dataset = dataset.apply(
tf.contrib.data.shuffle_and_repeat(buffer_size=batch_size * 10, count=num_epochs)
)
elif shuffle:
dataset = dataset.shuffle(buffer_size=batch_size * 10)
elif num_epochs is not None:
dataset = dataset.repeat(count=num_epochs)
dataset = dataset.apply(
tf.contrib.data.map_and_batch(map_func=parse_csv,
batch_size=batch_size,
num_parallel_calls=tf.data.experimental.AUTOTUNE)
)
I have another block below
distribution_strategy = tf.contrib.distribute.MirroredStrategy(num_gpus=num_gpus,
prefetch_on_device=True,
auto_shard_dataset=True)
如何在 Tensorflow 2.4.1 中实现同样的效果
【问题讨论】:
标签: python-3.x tensorflow tensorflow2.0