Reputation: 2741
I have a tensor of shape (60, 3, 32, 32)
and a boolean mask of shape (60, 32, 32)
. I want to apply this mask to the tensor. The output tensor should have shape (60, 3, 32, 32)
, and values are kept if the mask is 1, else 0.
How can I do that fast?
Upvotes: 1
Views: 759
Reputation: 8527
Let t
be the tensor and m
be the mask. You can use:
t * m.unsqueeze(1)
Upvotes: 3