Could Keras prefetch data like tensorflow Dataset?(Keras 可以预取 tensorflow Dataset 之类的数据吗?)
问题描述
在 TensorFlow 的 Dataset API 中,我们可以使用 dataset.prefetch(buffer_size=xxx)
来预加载其他批次的数据,而 GPU 正在处理当前批次的数据,因此,我可以充分利用 GPU.
In TensorFlow's Dataset API, we can use dataset.prefetch(buffer_size=xxx)
to preload other batches' data while GPU is processing the current batch's data, therefore, I can make full use of GPU.
我打算使用 Keras,想知道 keras
是否有类似的 API 让我充分利用 GPU,而不是串行执行:读取批处理 0->处理批处理 0->读取批次 1-> 处理批次 1-> ...
I'm going to use Keras, and wonder if keras
has a similar API for me to make full use of GPU, instead of serial execution: read batch 0->process batch 0->read batch 1-> process batch 1-> ...
我简要浏览了 keras
API,没有看到预取的描述.
I briefly looked through the keras
API and did not see a description of the prefetch.
推荐答案
如果调用 fit_generator
和 workers
> 1,使用_multiprocessing=True
,它将预取 queue_size 个批次.
If you call fit_generator
with workers
> 1, use_multiprocessing=True
, it will prefetch queue_size batches.
来自文档:max_queue_size:整数.生成器队列的最大大小.如果未指定,max_queue_size 将默认为 10.
From docs: max_queue_size: Integer. Maximum size for the generator queue. If unspecified, max_queue_size will default to 10.
这篇关于Keras 可以预取 tensorflow Dataset 之类的数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Keras 可以预取 tensorflow Dataset 之类的数据吗?


基础教程推荐
- matplotlib 设置 yaxis 标签大小 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- Kivy 使用 opencv.调整图像大小 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01