Python/Keras/Theano wrong dimensions for Deep Autoencoder

后端 未结 3 896
失恋的感觉
失恋的感觉 2021-01-02 08:34

I\'m trying to follow the Deep Autoencoder Keras example. I\'m getting a dimension mismatch exception, but for the life of me, I can\'t figure out why. It works when I use

3条回答
  •  星月不相逢
    2021-01-02 09:05

    The problem lies in:

    # retrieve the last layer of the autoencoder model
    decoder_layer = autoencoder.layers[-1]
    

    In previous model - the last layer was the only decoder layer. So it input was also an input to decoder. But right now you have 3 decoding layer so you have to go back to the first one in order to obtain decoder first layer. So changing this line to:

    # retrieve the last layer of the autoencoder model
    decoder_layer = autoencoder.layers[-3]
    

    Should do the work.

提交回复
热议问题