0
votes

I am using Tensorflow2. I have a fully connected auto-encoder DNN that I only want to use the decoder section after training. I want to give my input with the same shape as the output of the encoder and see the results of the decoder for this input. How is it possible?

def autoencoder_model(dims, act='relu', init='glorot_uniform'):
        n_stacks = len(dims) - 1
        # input
        input_img = Input(shape=(dims[0],), name='input')
        x = input_img
        skip = []
        # internal layers in encoder
        for i in range(n_stacks - 1):
            x = Dense(dims[i + 1], activation=act, kernel_initializer=init, name='encoder_%d' % I)(x)

        # hidden layer
        encoded = Dense(dims[-1], kernel_initializer=init, name='encoder_%d' % (n_stacks - 1))(
            x)  # hidden layer, features are extracted from here

        x = encoded

        # internal layers in decoder
        for i in range(n_stacks - 1, 0, -1):
            x = Dense(dims[i], activation=act, kernel_initializer=init, name='decoder_%d' % i)(x)

        x = Dense(dims[0], activation=None, kernel_initializer=init, name='decoder_0')(x)

        decoded = x
        return Model(inputs=input_img, outputs=[encoded, decoded], name='auto_encoder')