deep-learning - 如何从 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()
由于批量大小为 32,print(x_train) 为 (32,28,28,1)。我总共有 5000 个训练数据集,我想为 print(x_train) 获取 (5000,28,28,1)
解决方案
推荐阅读
- javascript - 如何将数字存储在数组中?
- css - MateralizeCSS(选项卡、可折叠、按钮)无法正常工作:React.js(渲染)
- sql-server - 如何从 Windows 10 家用计算机连接到 SQL Server?
- visual-studio - 从 SSIS 提取数据时出现 Odata 错误
- javascript - 有没有办法使用 Expo 获取设备的 IP 地址?
- java - 如何在 Java 中将 int 数据转换为压缩十进制
- css - 我可以选择具有类(任何类)的元素吗
- javascript - 如何在没有鼠标事件的情况下在openlayers中从其他世界中找到当前世界中的等效坐标
- html - 变量插入闪烁功能
- hive - HIve:表创建失败并显示“由于 OWN_TASK_FAILURE 导致顶点未成功”