Introduction singleton distribution in Normal distribution

I am trying to introduce new singleton dimension to a Normal distribution. I know I can access loc, scale and change them to get the desired distribution. I could use expand() to introduce new dimension as first dimensions. But what do I do if I want to introduce new dimension else where?

Given Normal of size [10,10,10], I want a distribution with shape [10,10,1,10]

The simplest way to do this is at the creation of the distribution, call .unsqueeze(2) on the loc and the scale argument tensors.

If you don’t want to do this, you can always create another distribution from the first one:

dist2 = torch.distributions.Normal(loc=dist1.loc.unsqueeze(2), scale=dist1.scale.unsqueeze(2))

I guess you are looking for a .unsqueeze() method for distributions, that would work like .expand(), but it does not exist. You could submit a PR or an issue on github but I don’t know if such a method would be very useful.

Thank you very much… I ultimately ended up doing the samething…