Keras可以预取诸如tensorflow Dataset之类的数据吗? [英] Could Keras prefetch data like 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.
推荐答案
如果使用workers
> 1调用fit_generator
,则使用use_ multiprocessing=True
,它将预取queue_size批处理.
If you call fit_generator
with workers
> 1, use_multiprocessing=True
, it will prefetch queue_size batches.
来自docs: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之类的数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!