Skip to content

kl_div problem #1

Description

@gooooney

Hello, I encountered some issues when running your code. Below is the error message. I think it might be due to some configuration or environment problems. May I ask what your environment configuration was when you ran this code? Thank you.


TypeError Traceback (most recent call last)
Cell In[40], line 4
2 cond_size = w_norm.shape[-1]
3 nlatent = 30
----> 4 cvae = CVAEModel( cond_size,input_dims, nlatent, layer_width=300)
7 def eval_loss(X,W, beta = 0.1 ):
8 Xhat ,z_out, kl_loss = cvae.vae_model([X,W])

Cell In[35], line 70
66 vae_params = self.encoder(X_in)
68 posterior_out = posterior(tf.keras.layers.concatenate(vae_params))
---> 70 kl_div = tfd.kl_divergence(tfd.MultivariateNormalDiag(loc = vae_params[0], scale_diag=vae_params[1] ), prior)
72 self.posterior_out = posterior_out
74 dec_output = input_dims

File c:\Users\A\anaconda3\envs\BB\lib\site-packages\tensorflow_probability\python\distributions\kullback_leibler.py:100, in kl_divergence(distribution_a, distribution_b, allow_nan_stats, name)
98 with distribution_a._name_and_control_scope(name + "_a"):
99 with distribution_b._name_and_control_scope(name + "_b"):
--> 100 kl_t = kl_fn(distribution_a, distribution_b, name=name)
101 if allow_nan_stats:
102 return kl_t

File c:\Users\A\anaconda3\envs\BB\lib\site-packages\tensorflow_probability\python\distributions\mvn_linear_operator.py:397, in _kl_brute_force(a, b, name)
391 else:
...
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb

TypeError: Dimension value must be integer or None or have an index method, got value '<attribute 'shape' of 'numpy.generic' objects>' with type '<class 'getset_descriptor'>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions