text_plain_output_1.png
from keras.layers import Conv2D, MaxPooling2D, GlobalMaxPooling2D

from keras.layers import Input, UpSampling2D

from keras.models import Sequential, load_model, Model

def autoencoder():
    inputs = Input(shape=(32, 32, 1))
    x = Conv2D(32, 3, activation='relu', padding='same')(inputs)
    x = MaxPooling2D(padding='same')(x)
    x = Conv2D(16, 3, activation='relu', padding='same')(x)
    x = MaxPooling2D(padding='same')(x)
    x = Conv2D(8, 3, activation='relu', padding='same')(x)
    encoded = MaxPooling2D(padding='same')(x)
    x = Conv2D(8, 3, activation='relu', padding='same')(encoded)
    x = UpSampling2D()(x)
    x = Conv2D(16, 3, activation='relu', padding='same')(x)
    x = UpSampling2D()(x)
    x = Conv2D(32, 3, activation='relu', padding='same')(x)
    x = UpSampling2D()(x)
    decoded = Conv2D(1, 3, activation='sigmoid', padding='same')(x)
    autoencoder = Model(inputs, decoded)
    autoencoder.compile(optimizer='nadam', loss='binary_crossentropy')
    return autoencoder

autoencoder = autoencoder()
autoencoder.summary()