我有一个CNN,其中输入是在每个通道0〜255之间具有值的RGB图像,而您的标签是在每个通道0〜255之间具有值的另一个RGB图像,但是 NN预测的值是1或0
训练NN时,产生的结果是一幅值在0到1之间的图像,但是用于训练和标记的图像的值在0〜255之间。
所有Conv2d和Conv2dTranpose都使用RELU激活(最后一个除外),而没有激活。
每个示例:在标签图像之后打印图像RGB的形状...,最后一个是预测NN:
print(X_train [0] [222] [1])
[34 45 32]
print(Y_train [0] [222] [1])
[22 43 44]
print(Img_predict [0] [222] [1])
[1 1 1]
输入=输入((IMG_HEIGHT,IMG_WIDTH,3))
c1 = Conv2D(16,(3,3),激活='elu',padding ='same')(输入)
c1 =辍学(0.3)(c1)
c1 = Conv2D(16,(3,3),激活='elu',padding ='same')(c1)
p1 = MaxPooling2D((2,2))(c1)
c2 = Conv2D(32,(3,3),激活='elu',padding ='same')(p1)
c2 =辍学(0.3)(c2)
c2 = Conv2D(32,(3,3),激活='elu',padding ='same')(c2)
p2 = MaxPooling2D((2,2))(c2)
c3 = Conv2D(64,(3,3),激活='elu',padding ='same')(p2)
c3 =辍学(0.3)(c3)
c3 = Conv2D(64,(3,3),activation ='elu',padding ='same')(c3)
u4 = Conv2DTranspose(32,(2,2),步幅=(2,2),padding ='same')(c5)
u4 =串联([u4,c2])
c4 = Conv2D(32,(3,3),activation ='elu',padding ='same')(u4)
c4 =辍学(0.3)(c4)
c4 = Conv2D(32,(3,3),activation ='elu',padding ='same')(c4)
u5 = Conv2DTranspose(16,(2,2),步幅=(2,2),padding ='same')(c4)
u5 =串联([u5,c1],轴= 3)
c5 = Conv2D(16,(3,3),激活='elu',padding ='same')(u5)
c5 =辍学(0.3)(c5)
cls_depth = Conv2D(3,(3,3),padding ='same')(c5)
如果将激活放在最后一层,则NN不会收敛。 预期结果为0到255之间的值,而不是0或1。