335 Star 1.5K Fork 865

MindSpore / docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
prefetch.md 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
俞涵 提交于 2023-01-29 16:21 . add mindquantum and modify url

Function Differences with tf.data.Dataset.prefetch

tf.data.Dataset.prefetch

tf.data.Dataset.prefetch(
    buffer_size
)

For more information, see tf.data.Dataset.prefetch.

mindspore.dataset.config.set_prefetch_size

mindspore.dataset.config.set_prefetch_size(
    size
)

For more information, see mindspore.dataset.config.set_prefetch_size.

Differences

TensorFlow: A method of the Dataset class, used to set the size of the current data pipeline cache queue.

MindSpore: A function to set the global size of all data pipeline cache queues.

Code Example

# The following implements set_prefetch_size with MindSpore.
import mindspore.dataset as ds

ds.config.set_prefetch_size(2)

# The following implements prefetch with TensorFlow.
import tensorflow as tf

data = tf.constant([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]])
dataset = tf.data.Dataset.from_tensor_slices(data)
dataset = dataset.prefetch(2)
1
https://gitee.com/mindspore/docs.git
git@gitee.com:mindspore/docs.git
mindspore
docs
docs
r2.0.0-alpha

搜索帮助

53164aa7 5694891 3bd8fe86 5694891