Rate this Page
★★★★★
torch.Tensor.masked_scatter#
- Tensor.masked_scatter(mask,tensor)→Tensor#
Out-of-place version of
torch.Tensor.masked_scatter_()Note
The inputs
selfandmaskbroadcast.Example
>>>self=torch.tensor([0,0,0,0,0])>>>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]])>>>self.masked_scatter(mask,source)tensor([[0, 0, 0, 0, 1], [2, 3, 0, 4, 5]])
On this page