Keras 可以预取 tensorflow Dataset 之类的数据吗?

2023-09-29Python开发问题
14

本文介绍了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_generatorworkers > 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 之类的数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

在xarray中按单个维度的多个坐标分组
groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)...
2024-08-22 Python开发问题
15

Pandas中的GROUP BY AND SUM不丢失列
Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)...
2024-08-22 Python开发问题
17

GROUP BY+新列+基于条件的前一行抓取值
Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)...
2024-08-22 Python开发问题
18

PANDA中的Groupby算法和插值算法
Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)...
2024-08-22 Python开发问题
11

PANAS-基于列对行进行分组,并将NaN替换为非空值
Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)...
2024-08-22 Python开发问题
10

按10分钟间隔对 pandas 数据帧进行分组
Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)...
2024-08-22 Python开发问题
11