我有一个深度学习模型,该模型将4d图像作为输入并预测1D图像。但是我的损失很高。谁能帮我找出原因。
样本输入图像: [第1维[] [1]] [1] + [第2维] [2] + [第3维] [3] + [第4维] [4] ====输出[所需的输出图像] [5] < / p>
包含输出图像的信息很少。
我使用RMSE来计算tf.keras的损失。它似乎没有收敛。
这是我的损失的样子:
第1/5集 25/27 [========================= ......]-ETA:1:16-损失:99.7717-acc:0.0000e +00
模型架构和模型拟合代码如下:
def unet(pretrained_weights = None,input_size = (512,512,4)):
inputs = Input(input_size)
conv1 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(inputs)
#conv1 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv1)
pool1 = MaxPooling2D(pool_size=(2, 2))(conv1)
conv2 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(pool1)
#conv2 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv2)
pool2 = MaxPooling2D(pool_size=(2, 2))(conv2)
conv3 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(pool2)
#conv3 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv3)
pool3 = MaxPooling2D(pool_size=(2, 2))(conv3)
conv4 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(pool3)
#conv4 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv4)
drop4 = Dropout(0.5)(conv4)
pool4 = MaxPooling2D(pool_size=(2, 2))(drop4)
conv5 = Conv2D(1024, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(pool4)
#conv5 = Conv2D(1024, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv5)
drop5 = Dropout(0.5)(conv5)
up6 = Conv2DTranspose(512, (2,2), strides=(2,2), padding='same')(drop5)
#merge6 = concatenate([drop4,up6], axis = 3)
merge6=up6
conv6 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(merge6)
#conv6 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv6)
up7 =Conv2DTranspose(256, (2,2), strides=(2,2), padding='same')(conv6)
#merge7 = concatenate([conv3,up7], axis = 3)
merge7=up7
conv7 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(merge7)
#conv7 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv7)
#up8 = Conv2D(128, 2, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(Conv2DTranspose(1, (3,3), strides=(2,2), padding='same')(conv7))
up8 = Conv2DTranspose(128, (2,2), strides=(2,2), padding='same')(conv7)
#merge8 = concatenate([conv2,up8], axis = 3)
merge8=up8
Conv2DTranspose(1, (3,3), strides=(2,2), padding='same')
conv8 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(merge8)
#conv8 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv8)
#up9 = Conv2D(64, 2, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(Conv2DTranspose(1, (3,3), strides=(2,2), padding='same')(conv8))
up9 = Conv2DTranspose(64, (2,2), strides=(2,2), padding='same')(conv8)
#merge9 = concatenate([conv1,up9], axis = 3)
merge9=up9
conv9 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(merge9)
#conv9 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv9)
#conv9 = Conv2D(2, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv9)
conv10 = Conv2D(1, 1, activation = 'sigmoid')(conv9)
conv11 = tf.keras.layers.Reshape((512, 512))(conv10)
model = tf.keras.Model(inputs,conv11)
model.compile(optimizer = Adam(lr = 1e-4), loss = 'binary_crossentropy', metrics = ['accuracy'])
#model.summary()
if(pretrained_weights):
model.load_weights(pretrained_weights)
return model
model=unet()
model.compile(loss=tf.keras.losses.MeanAbsolutePercentageError(),optimizer=tf.keras.optimizers.Adadelta(), metrics = ['accuracy'])
model.fit(train_ds,epochs=5,verbose=1,validation_data=validation_ds)
[1]: https://i.stack.imgur.com/h9x3C.png
[2]: https://i.stack.imgur.com/0LjZ4.png
[3]: https://i.stack.imgur.com/qu0cm.png
[4]: https://i.stack.imgur.com/ZiKlg.png
[5]: https://i.stack.imgur.com/f0izQ.png
答案 0 :(得分:0)
我认为您可以执行以下一些检查来找出问题所在: