You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently tried to use MixtureOfDiagNormals and ran across two issues while using it together with an AutoNormal guide.
The distributions MixtureOfDiagNormal and MixtureOfDiagNormalsSharedCovariance do not implement the support property, which leads to problems when using the distribution for latent variables and e.g. the AutoNormal guide. This can be solved easily by adding support = constraints.real_vector at the beginning of both classes. I assume that real_vector is the correct constraint here since D=1 is not supported anyways.
There seems to be a bug in the forward method of _MixDiagNormalSample. Specifically, when creating the white noise
white=locs.new(noise_shape).normal_()
This creates a new tensor of size (len(noise_shape),) instead of expected size noise_shape. This is actually done correctly in _MixDiagNormalSharedCovarianceSample with a call to torch.randn instead.
The correct way to do it would be
white=locs.new(*noise_shape).normal_()
However, since torch.Tensor.new does not appear in the PyTorch documentation (at least I didn't find it), I assume it is recommended to use a method like torch.Tensor.new_empty instead.
white=locs.new_empty(noise_shape).normal_()
works as expected. Alternatively, the same approach as for MixtureOfDiagNormalSharedCovariance is possible.
Package versions
PyTorch: version 2.0.1
Pyro: version 1.8.6
The text was updated successfully, but these errors were encountered:
* Added `support = constraints.real_vector` to `MixtureOfDiagNormals`
and `MixtureOfDiagNormalsSharedCovariance`
* Fixed the white noise sampling bug in the `forward` method of
`_MixDiagNormalSample`
* Same call in `_MixDiagNormalSample` and
`_MixDiagNormalSharedCovarianceSample` to generate white noise
* Harmonized tensor shape error messages between `MixtureOfDiagNormals`
and `MixtureOfDiagNormalsSharedCovariance`
* Added the correct class name in tensor shape errors for
`MixtureOfDiagNormalsSharedCovariance`
Problem description
I recently tried to use
MixtureOfDiagNormals
and ran across two issues while using it together with anAutoNormal
guide.MixtureOfDiagNormal
andMixtureOfDiagNormalsSharedCovariance
do not implement thesupport
property, which leads to problems when using the distribution for latent variables and e.g. theAutoNormal
guide. This can be solved easily by addingsupport = constraints.real_vector
at the beginning of both classes. I assume thatreal_vector
is the correct constraint here sinceD=1
is not supported anyways.forward
method of_MixDiagNormalSample
. Specifically, when creating the white noise(len(noise_shape),)
instead of expected sizenoise_shape
. This is actually done correctly in_MixDiagNormalSharedCovarianceSample
with a call totorch.randn
instead.The correct way to do it would be
torch.Tensor.new
does not appear in the PyTorch documentation (at least I didn't find it), I assume it is recommended to use a method liketorch.Tensor.new_empty
instead.MixtureOfDiagNormalSharedCovariance
is possible.Package versions
PyTorch: version 2.0.1
Pyro: version 1.8.6
The text was updated successfully, but these errors were encountered: