gpt4 book ai didi

python - 警告 : The calling iterator did not fully read the dataset being cached. 为了避免数据集的意外截断

转载 作者:行者123 更新时间:2023-12-03 20:48:29 24 4
gpt4 key购买 nike

这发生在我使用 tf.data.Dataset 时:

The calling iterator did not fully read the dataset being cached. In order to avoid unexpected truncation of the dataset, the partially cached contents of the dataset will be discarded. This can happen if you have an input pipeline similar to dataset.cache().take(k).repeat(). You should use dataset.take(k).cache().repeat() instead.


根据其他问题,例如 this one ,这跟哪里有关 cache()是在方法的顺序中,但我无法理解具体要做什么。
以下是重现警告的方法:
import tensorflow_datasets as tfds

ds = tfds.load('iris', split='train')

ds = ds.take(100)

for elem in ds:
pass
似乎无论我做什么,无论我在哪里使用 cache() ,弹出警告。

最佳答案

我试图在 Google colab 上运行您的代码,它成功运行而没有给出任何警告,我正在使用 Tensorflow 2.3 .
但是,您可以在使用 cache 时遵循这个通用方法。 .
如果数据集足够小以适合内存,您可以显着加快
使用数据集的 cache() 进行训练将其内容缓存到的方法RAM .您通常应该在加载和预处理后执行此操作
数据,但之前 shuffling , repeating , batching , 和 prefetching .这边走,
每个实例只会被读取和预处理一次(而不是每个时期一次)

关于python - 警告 : The calling iterator did not fully read the dataset being cached. 为了避免数据集的意外截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64305438/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com