【发布时间】:2018-07-24 09:13:40
【问题描述】:
我是 Keras 的新手。
我正在研究 Keras Xception 模型(2.2.0 版),我已成功使用 RGB 图像进行训练。
我的资源有限,因此将图像转换为灰度以减少数据大小(我不确定这是否正确,只是一种直觉)。我当前的数据集由灰度图像组成,并且与我研究 keras 预训练模型一样,需要 3 通道输入。我试过下面的代码来生成图像数据:
train_generator = train_datagen.flow_from_directory(
train_folder,
target_size=(img_width, img_height),
color_mode='grayscale',
batch_size=batch_size,
shuffle=True,
seed=seed)
然后构建模型如下:
model = xception.Xception(include_top=False, input_shape=(img_width, img_height, 1))
但我得到了错误:
ValueError:输入必须有3个通道;得到
input_shape=(257, 321, 1)
我已经在数据生成器功能中检查了 color_mode,但没有找到任何解决方案。 如果有人能帮助解决问题,将不胜感激!
【问题讨论】:
标签: python tensorflow keras