pytorch_flows icon indicating copy to clipboard operation
pytorch_flows copied to clipboard

Bug issue when running flows_01.ipynb

Open JoseAntonioSiguenza opened this issue 3 years ago • 0 comments

Hi!! Thanks for sharing this normalizing flow model with pytorch, it is really exciting.

When running the fifth cell of code a Value Error appears concerning the q1 distribution. It seems rare because the empirical values don't throw any problem. It may be a deprecated version of pytorch used back then. The following message appears:

ValueError Traceback (most recent call last) in () 1 q0_density = torch.exp(q0.log_prob(torch.Tensor(x))).numpy() ----> 2 q1_density = torch.exp(q1.log_prob(torch.Tensor(x))).numpy() 3 fig, (ax1, ax2) = plt.subplots(1, 2, sharex=True, figsize=(15, 5)) 4 ax1.plot(x, q0_density); ax1.fill_between(x, q0_density, 0, alpha=0.5) 5 ax1.set_title('$q_0 = \mathcal{N}(0,1)$', fontsize=18);

1 frames /usr/local/lib/python3.7/dist-packages/torch/distributions/distribution.py in _validate_sample(self, value) 287 if not valid.all(): 288 raise ValueError( --> 289 "Expected value argument " 290 f"({type(value).name} of shape {tuple(value.shape)}) " 291 f"to be within the support ({repr(support)}) "

ValueError: Expected value argument (Tensor of shape (1000,)) to be within the support (GreaterThan(lower_bound=0.0)) of the distribution TransformedDistribution(), but found invalid values.

The expected behaviour would be a density distribution for q1.

JoseAntonioSiguenza avatar Jan 19 '22 03:01 JoseAntonioSiguenza