Skip to content

Commit

Permalink
Updated docs to add the error case for torch.multinomial Issue#125388 (
Browse files Browse the repository at this point in the history
…pytorch#125495)

Summary: Updated docs to add the error condition for torch.multinomial

Test Plan: No change in code

Reviewers: @drisspg

Subscribers: @drisspg

Tasks:

Tags:

Fixes pytorch#125388

Pull Request resolved: pytorch#125495
Approved by: https://github.com/drisspg
  • Loading branch information
jainapurva authored and pytorchmergebot committed May 7, 2024
1 parent 3407899 commit c0c2f61
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions torch/_torch_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7873,9 +7873,8 @@ def merge_dicts(*dicts):
>>> weights = torch.tensor([0, 10, 3, 0], dtype=torch.float) # create a tensor of weights
>>> torch.multinomial(weights, 2)
tensor([1, 2])
>>> torch.multinomial(weights, 4) # ERROR!
RuntimeError: invalid argument 2: invalid multinomial distribution (with replacement=False,
not enough non-negative category to sample) at ../aten/src/TH/generic/THTensorRandom.cpp:320
>>> torch.multinomial(weights, 5) # ERROR!
RuntimeError: cannot sample n_sample > prob_dist.size(-1) samples without replacement
>>> torch.multinomial(weights, 4, replacement=True)
tensor([ 2, 1, 1, 1])
""".format(
Expand Down

0 comments on commit c0c2f61

Please sign in to comment.