# This is our encoded (32-dimensional) input encoded_input = keras.Input(shape=(encoding_dim,)) # Retrieve the last layer of the autoencoder model decoder_layer = autoencoder.layers[-1] # Create the decoder model decoder = keras.Model(encoded_input, decoder_layer(encoded_input))