【计算机视觉】卷积自编码器(用卷积层构建auto-encoder)

当输入是图像时,使用卷积神经网络是更好的。卷积自编码器的编码器部分由卷积层和MaxPooling层构成,MaxPooling负责空域下采样。而解码器由卷积层和上采样层构成。50个epoch后,损失val_loss: 0.1018。

input_img = Input(shape=(28, 28, 1))x = Convolution2D(16, (3, 3), activation='relu', padding='same')(input_img) x = MaxPooling2D((2, 2), padding='same')(x) x = Convolution2D(8, (3, 3), activation='relu', padding='same')(x) x = MaxPooling2D((2, 2), padding='same')(x) x = Convolution2D(8, (3, 3), activation='relu', padding='same')(x) encoded = MaxPooling2D((2, 2), padding='same')(x)x = Convolution2D(8, (3, 3), activation='relu', padding='same')(encoded) x = UpSampling2D((2, 2))(x) x = Convolution2D(8, (3, 3), activation='relu', padding='same')(x) x = UpSampling2D((2, 2))(x) x = Convolution2D(16, (3, 3), activation='relu')(x) x = UpSampling2D((2, 2))(x) decoded = Convolution2D(1, (3, 3), activation='sigmoid', padding='same')(x)autoencoder = Model(inputs=input_img, outputs=decoded) autoencoder.compile(optimizer='adadelta', loss='binary_crossentropy')# 打开一个终端并启动TensorBoard,终端中输入 tensorboard --logdir=/autoencoder autoencoder.fit(x_train, x_train, epochs=50, batch_size=256, shuffle=True, validation_data=https://www.it610.com/article/(x_test, x_test), callbacks=[TensorBoard(log_dir='autoencoder')])decoded_imgs = autoencoder.predict(x_test)

【计算机视觉】卷积自编码器(用卷积层构建auto-encoder)
文章图片

keras迁移学习——使用vgg19
【【计算机视觉】卷积自编码器(用卷积层构建auto-encoder)】keras预训练模型应用(3):VGG19提取任意层特征

    推荐阅读