【问题标题】:How to avoide ZeroPadding in convolutional neural network如何避免卷积神经网络中的零填充
【发布时间】:2020-01-10 11:07:13
【问题描述】:

我有一个卷积神经网络,它在我的数据集上比其他网络做得更好。问题在于ZeroPadding2D 我需要放置以说明向下/向上采样;它在输出中创建工件(零样本)。那么,如何在不改变网络结构(层)的情况下避免ZeroPadding2D 选项。我需要保持结构原样(no.layers)并且可能会改变 1-过滤器 2-内核 3- 我的数据中的第一个维度(例如 96) 4-任何其他选项 贝娄是我的 CNN

input_img = Input(shape=(96, 44, 1), name='full')  

x = GaussianNoise(.1)(input_img)
x = Conv2D(64, (5, 5), activation='relu', padding='same')(x)
x = AveragePooling2D((2, 2), padding='same')(x)
x = Dropout(0.1)(x)
x = Conv2D(128, (5, 5), activation='relu', padding='same')(x)
x = AveragePooling2D((2, 2), padding='same')(x)
x = Dropout(0.2)(x)
x = Conv2D(512, (5, 5), activation='relu', padding='same')(x)
encoded = AveragePooling2D((2, 2), padding='same')(x)
x = Dropout(0.2)(x)

# at this point the representation is (4, 4, 8) i.e. 128-dimensional
x = Conv2D(512, (5, 5), activation='relu', padding='same')(encoded)
x = UpSampling2D((2, 2))(x)
x = Dropout(0.2)(x)
x = Conv2D(128, (5, 5), activation='relu', padding='same')(x)
x = UpSampling2D((2, 2))(x)
x = Dropout(0.12)(x)
x = Conv2D(64, (3, 3), activation='relu')(x)
x = UpSampling2D((2, 2))(x)
x = Dropout(0.12)(x)
x = ZeroPadding2D(((4, 0), (0, 0)))(x)
decoded = Conv2D(1, (5, 5), activation='tanh', padding='same',
                 name='out')(x)

autoencoder = Model(input_img, decoded)

【问题讨论】:

    标签: python machine-learning keras conv-neural-network


    【解决方案1】:

    我想如果您将 Upsampling+ ZeroPadding 部分替换为 Conv2DTranspose ,这可能有助于解决您的问题。

    看看这里:

    https://www.tensorflow.org/api_docs/python/tf/keras/layers/Conv2DTranspose

    【讨论】:

      猜你喜欢
      • 2017-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-01
      • 2020-10-07
      • 2020-10-19
      相关资源
      最近更新 更多