1import keras
2from keras import layers
3
4# This is the size of our encoded representations
5encoding_dim = 32 # 32 floats -> compression of factor 24.5, assuming the input is 784 floats
6
7# This is our input image
8input_img = keras.Input(shape=(784,))
9# "encoded" is the encoded representation of the input
10encoded = layers.Dense(encoding_dim, activation='relu')(input_img)
11# "decoded" is the lossy reconstruction of the input
12decoded = layers.Dense(784, activation='sigmoid')(encoded)
13
14# This model maps an input to its reconstruction
15autoencoder = keras.Model(input_img, decoded)
16