如何从 ImageDataGenerator 获取 x_train?

问题描述

我正在研究图像分类 CNN,我想知道如何使用 ImageGenerator 获得 x_train 和 y_train 形式。这样做的原因是我想将我的模型拟合为 fit note fit.generator

trainDataGen = ImageDataGenerator(rescale= 1./255,rotation_range =30,width_shift_range=0.1,height_shift_range=0.1,shear_range=0.2,zoom_range=0.2,horizontal_flip=False,vertical_flip=False,fill_mode='nearest',)

trainGenSet = trainDataGen.flow_from_directory(
    path +'Train',target_size=(28,28),batch_size=32,class_mode='categorical',color_mode='grayscale',)


x_train,y_train = trainGenSet.next()

打印(x_train)是(32,28,1) 因为批量大小为 32。 我总共有 5000 个火车数据集 我想得到 (5000,1) for print(x_train)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...