-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Open
Labels
actionablemodule: distributionsRelated to torch.distributionsRelated to torch.distributionsmodule: docsRelated to our documentation, both in docs/ and docblocksRelated to our documentation, both in docs/ and docblockstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
π The doc issue
The doc of torch.bernoulli() shows its description as below:
torch.bernoulli(input: Tensor, *, generator: Optional[Generator], out: Optional[Tensor]) β Tensor
Draws binary random numbers (0 or 1) from a Bernoulli distribution.
...
For its signatures in codes, it showed like this:
@overload
def bernoulli(input: Tensor, *, generator: Optional[Generator] = None, out: Optional[Tensor] = None) -> Tensor:
@overload
def bernoulli(input: Tensor, p: _float, *, generator: Optional[Generator] = None) -> Tensor:
They diff on the param p
, for validate, repro below shows that torch.bernoulli()
can have this param:
Repro
import torch
import numpy as np
input_data = torch.empty(10, 2).uniform_(0, 1)
output_data = torch.bernoulli(input_data, 0.3)
print(output_data)
Output
tensor([[0., 0.],
[0., 0.],
[0., 0.],
[0., 0.],
[0., 1.],
[1., 0.],
[0., 0.],
[1., 0.],
[0., 0.],
[0., 1.]])
Suggest to fix the doc to meet the signatures in codes.
Thanks for noting.
Suggest a potential alternative/fix
- Suggest to fix the doc to meet the signature in codes.
cc @fritzo @neerajprad @alicanb @nikitaved @svekars @sekyondaMeta @AlannaBurke
Metadata
Metadata
Assignees
Labels
actionablemodule: distributionsRelated to torch.distributionsRelated to torch.distributionsmodule: docsRelated to our documentation, both in docs/ and docblocksRelated to our documentation, both in docs/ and docblockstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module