【发布时间】:2019-09-18 23:42:10
【问题描述】:
我正在尝试使用我自己的图像数据构建一个 inception 和 resnet 模型。该数据集共有 8000 张图像,有 6 个标签。构建模型时一切正常。但是提到的错误发生在model.fit()。
花了 14 小时后我真的不确定问题出在哪里。
我尝试了以下
更改图像尺寸顺序
对 keras.json 进行更改
更改模型中的 input_tensor 形状
inception_model = InceptionV3(input_tensor = inception_model.input, include_top = True, weights = 'imagenet')
inception_last_layer = inception_model.get_layer('predictions').output
inception_out = Dense(num_classes, activation='softmax', name='output')(inception_last_layer)
custom_inception = Model(inception_model.input, inception_out)
for layer in custom_inception.layers[:-3]:
layer.trainable = False
custom_inception.compile(loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy', 'mse', 'mae', 'mape'])
train_inception = custom_inception.fit(X_train, y_train, batch_size=8, epochs=2)
编辑:我目前正在使用 keras 2.2.0,在 github 中解决了一些 keras 问题后,我从最新版本降级了该版本。它确实解决了一些最初的问题。我目前正在使用它们各自的python文件中的inception和resnet,我对include_top=include_top进行了一些更改
require_flatten=include_top 来自this
EDIT2:这是输入形状
(1690, 220, 220, 1) is the X_train shape
(1690, 6) is the y_train
(423, 220, 220, 1) is the X_test shape
(423, 6) is the y_test
【问题讨论】:
-
能否提供X_train.shape和y_train.shape的结果?
-
当然我会在几秒钟内添加一个详细的 png 形状
-
你可以直接复制粘贴结果,用
python隔开,这样会更干净。 -
对象是什么:inception_model.input,是张量吗?如果您使用的是 [this version fo inception] (github.com/keras-team/keras-applications/blob/master/…),看起来您的模型在构造函数中不需要此参数。
-
是的,它是一个带形状的张量(None, image_rows, image_cols, channels)
标签: keras deep-learning