python的小tips 1 利用pytorch生成掩膜,去掉不想要的值 1 利用pytorch生成掩膜,去掉不想要的值 import torch import numpy as np a = [1,0,1,0,1,0] b = [1,2,3,4,5,6] a = torch.from_numpy(np.array(a)) b = torch.from_numpy(np.array(b)) c = b[a>0] c: tensor([1, 3, 5])