I followed the tutorial "Creating Auto Coders in Keras": https://blog.keras.io/building-autoencoders-in-keras.html
The first, simple solution works fine. But in the "Deep autoencoder" section, the code presented in the tutorial does not work fully.
Here is my code (until the problem appears) that is just copied from turorial:
from keras.layers import Input, Dense from keras.models import Model encoding_dim = 32 input_img = Input(shape=(784,)) encoded = Dense(128, activation='relu')(input_img) encoded = Dense(64, activation='relu')(encoded) encoded = Dense(32, activation='relu')(encoded)
I get this error:
Traceback (most recent call last): File "keras_test.py", line 20, in <module> decoder = Model(encoded_input, decoder_layer(encoded_input))
I assume that the decoder is associated with the wrong level of decoding and / or that the form of its input or output is incorrect. But what should I do about it?
autoencoder does not require a decoder for autoencoder . I can do the training and encode images by following the rest of the tutorial. But without a decoder I cannot decode the images back to the original format to see if they really look good. This tutorial says nothing about it, and it just shows decoded images without words. I assume that the author suggested that the changes he made for the decoder to achieve this were trivial.
To clarify: the single-layer version works fine, where instead of 3 coding and 3 decoding levels, we only have
encoded = Dense(32, activation='relu')(input_img) decoded = Dense(784, activation='sigmoid')(encoded)
and everything else is the same as above. Then there is no error, and I can use decoder to recreate the images.