pytorch中几种tensor掩码的获取方法(含代码)
方式一:直接取布尔值输入:target = torch.Tensor([1,0,0,2,0,0,3])mask = (target > 0)masked_target = target[mask]print(target)print(mask)print(masked_target)输入:target = torch.Tensor([1,0,0,2,0,0,3])mask = target.ge(0)masked_target = torch.masked_sel.