Skip to content

Wrong values of a Beta distribution sampling if the last dimension of the shape is 1 #10118

@nicola-decao

Description

@nicola-decao

Issue description

Errors occur when sampling from a Beta distribution if the last dimension of the shape is 1.

Code example

Sampling with shape [64, 2] returns correct values an a correct shape:

>>> torch.distributions.Beta(2,2).sample(torch.Size([64,2]))
tensor([[0.5614, 0.6955],
        [0.7505, 0.9468],
        [0.3592, 0.3131],
        [0.6340, 0.2711],
        [0.5731, 0.7529],
        [0.7051, 0.4502], ...

Sampling with shape [64, 1] returns wrong values (always 0.5 and some NaNs) an a correct shape:

>>> torch.distributions.beta.Beta(2,2).sample(torch.Size([64,1]))
tensor([[0.5000],
        [0.5000],
        [0.5000],
        [0.5000],
        [   nan],
        [0.5000],
        [0.5000], ...

System Info

PyTorch version: 0.4.1
Is debug build: No
CUDA used to build PyTorch: None

OS: Ubuntu 16.04.4 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
CMake version: Could not collect

Python version: 3.6
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip] Could not collect
[conda] pytorch-cpu               0.4.1                py36_cpu_1    pytorch
[conda] torchvision-cpu           0.2.1                    py36_1    pytorch

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions