Torch.normal issues error for negative sigma

I found this problem recently - it was working fine earlier. When I give

a = torch.distributions.Normal(0,-1)

it results in

ValueError: The parameter scale has invalid values

This has been raised on Github following some discussions but it still does not seem to work. Any ideas regarding this error?

Hi Kirty!

Well, I wouldn’t say it was “working fine earlier.” Rather, Normal
was failing to complain about an invalid negative value for scale
(sigma) in some situations.

Speaking from memory, pytorch used to complain about negative
scale in some, but not all situations, but the error checking has
been tightened up in more recent versions.

Also, from memory, when instantiated with negative scale, Normal
behaved (more or less) as if it had been instantiated as:

torch.distributions.Normal (0, abs (scale))

You could conceivably use abs() as a work-around to recover the
old behavior, but be cautious about sweeping the likely error under
the rug – you should be figuring out where your negative scale is
coming from and whether it really makes mathematical sense.


K. Frank

1 Like