print(Train_y.shape)
locs0 = (Train_y == 0)
locs1 = (~locs0)
print(locs0.sum())
print(locs1.sum())

(512,)
270
242

Train_x, Train_y = torch.FloatTensor(Train_x), torch.FloatTensor(Train_y)
 locs0 = (Train_y == 0)
 locs1 = (~locs0)
print(torch.sum(locs0))
print(torch.sum(locs1))
8
242

print(x5.shape)
x5_negx = x5[locs0]
x5_posx = x5[locs1]
print(x5_negx.shape)
print(x5_posx.shape)

torch.Size([512, 1, 100, 100])
torch.Size([264, 1, 100, 100])
torch.Size([248, 1, 100, 100])