检索不为0的: import torch x = torch.Tensor([0,1,10,0,1]) print( torch.nonzero(x).squeeze()) 检索别的数据,可以转换为这个函数可用的