Вы можете сложить их:
import torch
torch.manual_seed(2020)
# x is a fake data, it should be your tensor with 64x2941
x = (torch.rand((3,4)) > 0.5).to(torch.int32)
print(x)
# tensor([[0, 0, 1, 0],
# [0, 0, 1, 1],
# [0, 1, 1, 1]], dtype=torch.int32)
ones = (x == 1.).sum(dim=0)
print(ones)
# tensor([0, 1, 3, 2])
И если x
является двоичным, вы можете получить число нулей простым вычитанием:
zeros = x.shape[1] - ones