Distribution Error: The value argument must be within the support

So, I found this cool Normalizing flow tutorial in PyTorch and I was trying the first tut itself link here

import torch.distributions as distrib
import torch.distributions.transforms as transforms


x = np.linspace(-4, 4, 1000)
z = np.array(np.meshgrid(x, x)).transpose(1, 2, 0)
z = np.reshape(z, [z.shape[0] * z.shape[1], -1])

And the transformations like

# Initial distribution
q0 = distrib.MultivariateNormal(torch.zeros(2), torch.eye(2))
# Defining Affine Transformation
f1 = transforms.ExpTransform()
# Transforming
q1 = distrib.TransformedDistribution(q0, f1)

---> q1.log_prob(torch.Tensor(z))

The last line raises ValueError: The value argument must be within the support which is not the case in the notebook did something change? Because I tried running the whole notebook on colab and it broke there too and on my system too.
Any help what might be wrong?

2 Likes

Any workaround for this?

1 Like

Hello,

It is late for your work, but I hope it will be helpful for others.
You can check this link : ValueError: The value argument must be within the support · Issue #59228 · pytorch/pytorch · GitHub

you should just add (validate_args=False) :
q0 = distrib.MultivariateNormal(torch.zeros(2), torch.eye(2),validate_args=False)

Define an affine transform

f1 = transform.ExpTransform()
q1 = distrib.TransformedDistribution(q0, f1, validate_args=False)