我对卷积自动编码器有疑问,希望有人能帮助我。
我的输入图像有3个通道,大小为256x256。我用这些图像(总共约3000个)训练了具有几个卷积层(relu激活)的卷积自动编码器。每个转换层后都有一个BatchNormalization以及Maxpooling。
在编码器部分,图像被压缩为1x1x4的大小,并且输出端的重构看起来非常完美。
现在,我绘制了每个卷积层的激活图,并注意到最后两个卷积层的特征图只是黑色。
它们不完全是零,但是值很小。
我现在的问题是,是否可以对图像进行这么多的压缩,为什么我的特征图是黑色的?
我想使用自动编码器进行特征提取,但是如果激活量很小,从瓶颈层提取特征似乎毫无意义。
预先感谢您的任何建议:-)
干杯
迈克尔
您好,感谢您的快速回复!
这是我的网络的样子:
conv1 = Conv2D(256, (3, 3), activation='relu', padding='same')(input_img)
conv1 = BatchNormalization()(conv1)
conv1 = Conv2D(256, (3, 3), activation='relu', padding='same')(conv1)
conv1 = BatchNormalization()(conv1)
pool1 = MaxPooling2D(pool_size=(2, 2))(conv1)
conv2 = Conv2D(224, (3, 3), activation='relu', padding='same')(pool1)
conv2 = BatchNormalization()(conv2)
conv2 = Conv2D(224, (3, 3), activation='relu', padding='same')(conv2)
conv2 = BatchNormalization()(conv2)
pool2 = MaxPooling2D(pool_size=(2, 2))(conv2)
conv3 = Conv2D(192, (3, 3), activation='relu', padding='same')(pool2)
conv3 = BatchNormalization()(conv3)
conv3 = Conv2D(192, (3, 3), activation='relu', padding='same')(conv3)
conv3 = BatchNormalization()(conv3)
pool3 = MaxPooling2D(pool_size=(2, 2))(conv3)
conv4 = Conv2D(128, (3, 3), activation='relu', padding='same')(pool3)
conv4 = BatchNormalization()(conv4)
conv4 = Conv2D(128, (3, 3), activation='relu', padding='same')(conv4)
conv4 = BatchNormalization()(conv4)
pool4 = MaxPooling2D(pool_size=(2, 2))(conv4)#14 x 14 x 32
conv5 = Conv2D(96, (3, 3), activation='relu', padding='same')(pool4)
conv5 = BatchNormalization()(conv5)
conv5 = Conv2D(96, (3, 3), activation='relu', padding='same')(conv5)
conv5 = BatchNormalization()(conv5)
pool5 = MaxPooling2D(pool_size=(2, 2))(conv5)
conv6 = Conv2D(64, (3, 3), activation='relu', padding='same')(pool5)
conv6 = BatchNormalization()(conv6)
conv6 = Conv2D(64, (3, 3), activation='relu', padding='same')(conv6)
conv6 = BatchNormalization()(conv6)
pool6 = MaxPooling2D(pool_size=(2, 2))(conv6)
conv7 = Conv2D(32, (3, 3), activation='relu', padding='same')(pool6)
conv7 = BatchNormalization()(conv7)
conv7 = Conv2D(32, (3, 3), activation='relu', padding='same')(conv7)
conv7 = BatchNormalization()(conv7)
pool7 = MaxPooling2D(pool_size=(2, 2))(conv7)
conv8 = Conv2D(16, (3, 3), activation='relu', padding='same')(pool7)
conv8 = BatchNormalization()(conv8)
conv8 = Conv2D(16, (3, 3), activation='relu', padding='same')(conv8)
conv8 = BatchNormalization()(conv8)
pool8 = MaxPooling2D(pool_size=(2, 2))(conv8)
conv9 = Conv2D(8, (3, 3), activation='relu', padding='same')(pool8)
conv9 = BatchNormalization()(conv9)
conv9 = Conv2D(8, (3, 3), activation='relu', padding='same')(conv9)
conv9 = BatchNormalization()(conv9)
conv10 = Conv2D(4, (3, 3), activation='relu', padding='same')(conv9)
conv10 = BatchNormalization()(conv10)
conv10 = Conv2D(4, (3, 3), activation='relu', padding='same', name='encoder')(conv10)
conv10 = BatchNormalization()(conv10)
#decoder
up11 = concatenate([conv10, conv9],axis=3)
conv11 = Conv2D(8, (3, 3), activation='relu', padding='same')(up11)
conv11 = BatchNormalization()(conv11)
conv11 = Conv2D(8, (3, 3), activation='relu', padding='same')(conv11)
conv11 = BatchNormalization()(conv11)
up12 = UpSampling2D((2, 2))(conv9) # 14 x 14 x 128
up12 = concatenate([up12,conv8], axis = 3)
conv12 = Conv2D(16, (3, 3), activation='relu', padding='same')(up12)
conv12 = BatchNormalization()(conv12)
conv12 = Conv2D(16, (3, 3), activation='relu', padding='same')(conv12)
up13 = UpSampling2D((2, 2))(conv12) # 14 x 14 x 128
up13 = concatenate([up13,conv7], axis = 3)
conv13 = Conv2D(32, (3, 3), activation='relu', padding='same')(up13)
conv13 = BatchNormalization()(conv13)
conv13 = Conv2D(32, (3, 3), activation='relu', padding='same')(conv13)
up14 = UpSampling2D((2, 2))(conv13)
up14 = concatenate([up14, conv6], axis=3)
conv14 = Conv2D(64, (3, 3), activation='relu', padding='same')(up14)
conv14 = BatchNormalization()(conv14)
conv14 = Conv2D(64, (3, 3), activation='relu', padding='same')(conv14)
up15 = UpSampling2D((2, 2))(conv14)
up15 = concatenate([up15, conv5], axis=3)
conv15 = Conv2D(96, (3, 3), activation='relu', padding='same')(up15)
conv15 = BatchNormalization()(conv15)
conv15 = Conv2D(96, (3, 3), activation='relu', padding='same')(conv15)
conv15 = BatchNormalization()(conv15)
up16 = UpSampling2D((2, 2))(conv15)
up16 = concatenate([up16, conv4], axis=3)
conv16 = Conv2D(128, (3, 3), activation='relu', padding='same')(up16)
conv16 = BatchNormalization()(conv16)
conv16 = Conv2D(128, (3, 3), activation='relu', padding='same')(conv16)
conv16 = BatchNormalization()(conv16)
up17 = UpSampling2D((2, 2))(conv16)
up17 = concatenate([up17, conv3], axis=3)
conv17 = Conv2D(192, (3, 3), activation='relu', padding='same')(up17)
conv17 = BatchNormalization()(conv17)
conv17 = Conv2D(192, (3, 3), activation='relu', padding='same')(conv17)
conv17 = BatchNormalization()(conv17)
up18 = UpSampling2D((2, 2))(conv17)
up18 = concatenate([up18, conv2], axis=3)
conv18 = Conv2D(224, (3, 3), activation='relu', padding='same')(up18)
conv18 = BatchNormalization()(conv18)
conv18 = Conv2D(224, (3, 3), activation='relu', padding='same')(conv18)
conv18 = BatchNormalization()(conv18)
up19 = UpSampling2D((2, 2))(conv18)
up19 = concatenate([up19, conv1], axis=3)
conv19 = Conv2D(256, (3, 3), activation='relu', padding='same')(up19)
conv19 = BatchNormalization()(conv19)
conv19 = Conv2D(256, (3, 3), activation='relu', padding='same')(conv19)
conv19 = BatchNormalization()(conv19)
decoded = Conv2D(channels, (3, 3), activation='sigmoid', padding='same')(conv19)
model = Model(input_img, decoded)
返回模型 我在编码器部分(convv10)的最后一个卷积层提取了特征,其名称为'encoder'。
我不使用任何L1 / L2正则化。
所有特征(像素)在0-1之间归一化。
干杯
迈克尔
编辑:附加注释:这是我在绘制要素时从编码器图层映射的样子:
从编码器层提取的功能图
当我将鼠标悬停在要素地图上时,我看到1-2可能为零,而其他像素的像素值可能为1.8或3.1。
虽然我不理解为什么绘制了全黑的图形,但是我想这取决于其他要素图值的范围吗?
->另一个编辑:刚刚检查了来自第一卷积层的要素图的值。它们在相同范围内。相对较高的激活率是0.3-0.4 ....这仅仅是matplotlib的绘图对象吗?
好的,首先对所有编辑和更正感到遗憾。
我刚刚将编码层的要素图与numpy串联在一起,现在看起来像这样:
级联特征图
好像matplotlib在某种程度上正在规范化。看起来更好:-)
但是,如果我回到我的问题:
那么像我一样多压缩图像是合理的吗?除了BatchNormalization之外,您还会推荐L2规范化吗?
再次感谢
欢呼
迈克尔