我正在尝试在Keras中训练CNN模型用于图像抠像。我尝试了不同的模型,但问题一直在发生。在开始训练之后,经过一些时期后,损失变为0.3385,并且在达到这一点后,损失永远不会改变。 这种情况发生后,我中断了训练并重新开始。有时这可以解决问题,有时则不能。同样,当发生这种情况时,我会查看预测,输出全为黑色。通常,它应该给我一些灰度遮罩。
我尝试禁用回调,但没有成功。我已经训练了100次模型,然后保存了模型。然后我加载它来训练另外100次。损失并没有停留在前100个时期。这可能与问题有关吗?我该怎么解决?
谢谢。
Epoch 144/200
50/50 [==============================] - 2s 35ms/step - loss: 1.0376e-04 - val_loss: 0.3642
Epoch 145/200
50/50 [==============================] - 2s 35ms/step - loss: 1.0175e-04 - val_loss: 0.3642
Epoch 146/200
50/50 [==============================] - 2s 36ms/step - loss: 0.2364 - val_loss: 0.3640
Epoch 147/200
50/50 [==============================] - 2s 35ms/step - loss: 0.3385 - val_loss: 0.3640
Epoch 148/200
50/50 [==============================] - 2s 36ms/step - loss: 0.3385 - val_loss: 0.3640
Epoch 149/200
50/50 [==============================] - 2s 35ms/step - loss: 0.3385 - val_loss: 0.3640
Epoch 150/200
50/50 [==============================] - 2s 35ms/step - loss: 0.3385 - val_loss: 0.3640
Epoch 151/200
50/50 [==============================] - 2s 36ms/step - loss: 0.3385 - val_loss: 0.3640
Epoch 152/200
50/50 [==============================] - 2s 34ms/step - loss: 0.3385 - val_loss: 0.3640
Epoch 153/200
50/50 [==============================] - 2s 35ms/step - loss: 0.3385 - val_loss: 0.3640
Epoch 154/200
50/50 [==============================] - 2s 36ms/step - loss: 0.3385 - val_loss: 0.3640
这是我的模型:
x = Conv2D(32, (3, 3), activation='relu', padding='same')(input_image)
x = Conv2D(32, (3, 3), activation='relu', padding='same')(x)
x = MaxPooling2D((3, 3), padding='same')(x)
x = Conv2D(64, (3, 3), activation='relu', padding='same')(x)
x = Conv2D(64, (3, 3), activation='relu', padding='same')(x)
x = Conv2D(64, (3, 3), activation='relu', padding='same')(x)
x = MaxPooling2D((2, 2), padding='same')(x)
x = Conv2D(128, (3, 3), activation='relu', padding='same')(x)
x = Conv2D(128, (3, 3), activation='relu', padding='same')(x)
encoded = MaxPooling2D((2, 2), padding='same')(x)
x = Conv2D(128, (3, 3), activation='relu', padding='same')(encoded)
x = Conv2D(128, (3, 3), activation='relu', padding='same')(x)
x = UpSampling2D((2, 2))(x)
x = Conv2D(64, (3, 3), activation='relu', padding='same')(x)
x = Conv2D(64, (3, 3), activation='relu', padding='same')(x)
x = Conv2D(64, (3, 3), activation='relu', padding='same')(x)
x = UpSampling2D((2, 2))(x)
x = Conv2D(32, (3, 3), activation='relu', padding='same')(x)
x = Conv2D(32, (3, 3), activation='relu', padding='same')(x)
x = UpSampling2D((3, 3))(x)
decoded = Conv2D(1, (3, 3), activation='relu', padding='same')(x)
autoencoder = Model(input_image, decoded)
autoencoder.compile(optimizer='adam', loss='mean_squared_error')