我在keras中使用以下代码
来自keras.layers导入输入,密集,Conv2D,MaxPooling2D,UpSampling2D来自keras.models导入模型来自keras导入后端为K.
input_img =输入(形状= …
这种情况正在发生,因为“相同”的行为与此无关 strides !=1 。您是否尝试将步幅指定为1? 该问题将详细讨论 这里
strides !=1
input_img = Input(shape=(28, 28, 1)) x = Conv2D(32, (3, 3), activation='relu', padding='same')(input_img) x = MaxPooling2D((2, 2), padding='same')(x) x = Conv2D(32, (3, 3), activation='relu', padding='same')(x) encoded = MaxPooling2D((2, 2), padding='same')(x) # at this point the representation is (7, 7, 32) x = Conv2D(32, (3, 3), activation='relu', padding='same')(encoded) x = UpSampling2D((2, 2))(x) x = Conv2D(32, (3, 3), activation='relu', padding='same')(x) x = UpSampling2D((2, 2))(x) decoded = Conv2D(1, (3, 3), activation='sigmoid', padding='same')(x)
现在,如果我使用上面的代码,我不需要省略第二个最后一个conv2D块的padding ='same'及其工作