Coming from Torch7 I am missing logical operations such as the any() and all() functions to check whether a Boolean Tensor contains either only zeros or ones (e.g. after another logical operation):
I understand I could probably do something like
a = torch.rand(3,3)
torch.sum(torch.lt(a,1)) / torch.numel(a)
and check whether this is 1 or 0 (result is a byte tensor so this should be integer division), but it feels rather inconvenient.
Is there some equivalent in PyTorch and if not, would it be possible to add these functions?
thanks for the super quick response. That’s exactly what I need.
Sorry if I didn’t look hard enough and my question was perhaps trivial, but I don’t seem to be able to find it in the documentation neither under tensor, nor where all the other comparison ops are listed in math: