Hello I have some errors while implementing variational autoencoder

0 votes
def dense_layers(sizes):
    return tfk.Sequential([tfkl.Dense(size, activation=tf.nn.leaky_relu) for size in sizes])
encoder = tfk.Sequential([
    tfkl.InputLayer(input_shape=input_shape, name='encoder_input'),
    dense_layers(intermediary_dims),
    tfkl.Dense(latent_dim, activation = tf.nn.leaky_relu),
    tfkl.Dense(tfpl.MultivariateNormalTriL.params_size(latent_dim), activation=None),
    tfpl.MultivariateNormalTriL(latent_dim,activity_regularizer=tfpl.KLDivergenceRegularizer(prior)),
], name='encoder')

encoder.summary()
plot_model(encoder, to_file='vae_mlp_encoder.png', show_shapes=True)

decoder = tfk.Sequential([
    tfkl.InputLayer(input_shape=[latent_dim]),
    dense_layers(reversed(intermediary_dims)),
    tfkl.Dense(tfpl.IndependentNormal.params_size(original_dim), activation=None),
    tfpl.IndependentNormal(original_dim),
], name='decoder')

decoder.summary()
plot_model(decoder, to_file='vae_mlp_decoder.png', show_shapes=True)

vae = tfk.Model(inputs=encoder.inputs,
                outputs=decoder(encoder.outputs[0]),
                name='vae_mlp')

negloglik = lambda x, rv_x: -rv_x.log_prob(x)

vae.compile(optimizer=tf.keras.optimizers.Nadam(), 
            loss=negloglik)

vae.summary()
plot_model(vae,
           to_file='vae_mlp.png',
           show_shapes=True)




---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

<ipython-input-29-236f8f195100> in <module>()
      7     tfkl.Dense(tfpl.MultivariateNormalTriL.params_size(latent_dim), activation=None),
      8     tfpl.MultivariateNormalTriL(latent_dim,activity_regularizer=tfpl.KLDivergenceRegularizer(prior)),
----> 9 ], name='encoder')
     10 
     11 encoder.summary()


9 frames

/usr/local/lib/python3.6/dist-packages/tensorflow_probability/python/layers/distribution_layer.py in kl_divergence_fn(distribution_a, distribution_b)
   1086       z = test_points_fn(distribution_a)
   1087       return tf.reduce_mean(
-> 1088           distribution_a.log_prob(z) - distribution_b.log_prob(z),
   1089           axis=test_points_reduce_axis)
   1090 


AttributeError: 'Tensor' object has no attribute 'log_prob'


May 19, 2019 in Machine Learning by anonymous

edited May 20, 2019 by Omkar 1,357 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Machine Learning

0 votes
1 answer

How do I create a decision tree?

Let us consider the following example. Suppose a ...READ MORE

answered May 13, 2019 in Machine Learning by Fatima
879 views
0 votes
1 answer
0 votes
0 answers
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,391 views
0 votes
1 answer
0 votes
2 answers

ModuleNotFoundError: No module named 'tensorflow'

If you are using Anaconda, go to ...READ MORE

answered Nov 17, 2020 in Machine Learning by Vignesh

edited Aug 11, 2021 by Soumya 17,572 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP