Python/Keras/Theano wrong dimensions for Deep Autoencoder

后端 未结 3 864
失恋的感觉
失恋的感觉 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:11

    You need to apply the transformation from each decoder layer to the previous. You can manually unroll and hard code these as in the accepted answer, or the following loop should take care of it:

    # create a placeholder for an encoded (32-dimensional) input
    encoded_input = Input(shape=(encoding_dim,))
    
    # retrieve the decoder layers and apply to each prev layer
    num_decoder_layers = 3
    decoder_layer = encoded_input
    for i in range(-num_decoder_layers, 0):
        decoder_layer = autoencoder.layers[i](decoder_layer)
    
    # create the decoder model
    decoder = Model(encoded_input, decoder_layer)
    

提交回复
热议问题