Hi,
I have a target tensor that I want to one hot encode and finally filter with a binary mask originally based on the target tensor.
# target tensor
t = torch.Tensor(4, 5, 5).random_(0, 10).long()
# binary mask
m = t == 3
# one hot encoded tensor
et = torch.Tensor(4, 10, 5, 5).zero_()
# one hot encoding
et.scatter_(1, t.unsqueeze(1), 1)
# expand the binary mask to match the new one-hot encoded target
m = m.unsqueeze(1).expand(et.size())

# should print a vector of ones, but does not
print(et[~m].view(10, -1).sum(0))

After filtering with the mask, I cannot manage to find a correct view for having back to encoded targets.
Thanks