mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Fix doc example of masked_scatter (#123664)
mask has to be a bool tensor Pull Request resolved: https://github.com/pytorch/pytorch/pull/123664 Approved by: https://github.com/peterbell10, https://github.com/albanD
This commit is contained in:
parent
adcfc2b582
commit
d6fb1da806
|
|
@ -3167,7 +3167,7 @@ Args:
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
>>> self = torch.tensor([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]])
|
>>> self = torch.tensor([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]])
|
||||||
>>> mask = torch.tensor([[0, 0, 0, 1, 1], [1, 1, 0, 1, 1]])
|
>>> mask = torch.tensor([[0, 0, 0, 1, 1], [1, 1, 0, 1, 1]], dtype=torch.bool)
|
||||||
>>> source = torch.tensor([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]])
|
>>> source = torch.tensor([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]])
|
||||||
>>> self.masked_scatter_(mask, source)
|
>>> self.masked_scatter_(mask, source)
|
||||||
tensor([[0, 0, 0, 0, 1],
|
tensor([[0, 0, 0, 0, 1],
|
||||||
|
|
@ -6584,7 +6584,7 @@ Out-of-place version of :meth:`torch.Tensor.masked_scatter_`
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
>>> self = torch.tensor([0, 0, 0, 0, 0])
|
>>> self = torch.tensor([0, 0, 0, 0, 0])
|
||||||
>>> mask = torch.tensor([[0, 0, 0, 1, 1], [1, 1, 0, 1, 1]])
|
>>> mask = torch.tensor([[0, 0, 0, 1, 1], [1, 1, 0, 1, 1]], dtype=torch.bool)
|
||||||
>>> source = torch.tensor([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]])
|
>>> source = torch.tensor([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]])
|
||||||
>>> self.masked_scatter(mask, source)
|
>>> self.masked_scatter(mask, source)
|
||||||
tensor([[0, 0, 0, 0, 1],
|
tensor([[0, 0, 0, 0, 1],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user