I have a 2D bool tensor mask
and I would like to update its values at the intersection of the given row and col indices, like the following:
mask = torch.zeros(5,3, dtype=torch.bool)
rows = torch.tensor([0,2,4])
cols = torch.tensor([1,2])
mask[rows, cols] = True
But I receive the following error:
IndexError: shape mismatch: indexing tensors could not be broadcast together with shapes [3], [2]
The desired output is:
tensor([[False, True, True ],
[False, False, False],
[False, True, True ],
[False, False, False],
[False, True, True ]])
How is that possible in PyTorch?