Keras flow

编程入门 行业动态 更新时间:2024-10-10 13:15:12
本文介绍了Keras flow_from_directory限制示例数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Keras中使用flow_from_directory并将每个子目录中使用的示例数限制为一定数量N时,最简单的方法是什么?

What's the simplest way I can use flow_from_directory in Keras while limiting the number of examples used in each subdirectory by some number N?

对于上下文,我希望能够使用全部图像的一小部分进行测试,而不必为较小的数据集创建单独的顶级目录,因为我是从AWS S3存储桶中提取此数据的在训练期间.

For context, I'd like to be able to use a small subset of the total images for testing purposes without having to create a separate top level directory for the smaller dataset, since I'm pulling this data from AWS S3 buckets during training.

推荐答案

使用参数validation_split指定为float的方式创建keras.preprocessing.image.ImageDataGenerator.在这种情况下,可以在flow_from_directory中使用参数subset从每个目录中仅获取一些样本.更多信息此处.

Create keras.preprocessing.image.ImageDataGenerator with argument validation_split specified as float. In such case you can use argument subset in flow_from_directory to get only some samples from each directory. More info here.

如果要从每个文件夹中专门获取N个图像,则必须计算每个目录中有多少个文件,并相应地设置训练验证拆分.

If you want N images from each folder specifically, you would have to calculate how many files are there in each directory, and set train-validation split accordingly.

更多推荐

Keras flow

本文发布于:2023-11-25 11:18:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629537.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Keras   flow

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!