pytorch~改变tensor的值(对mask进行0\1化操作)

1
2
3
4
5
6
7
new_mask_image = torch.zeros([inst_map.shape[0],inst_map.shape[1],inst_map.shape[2],inst_map.shape[3]], dtype=torch.float32,device=inst_map.device)
for i in range(inst_map.shape[0]):           
            f_mask = inst_map [i,:,:,:]
            zero = torch.zeros_like(f_mask)
            one  = torch.ones_like(f_mask)
            f_mask= torch.where(f_mask> -1.0, one, zero)
            new_mask_image[i,:,:,:] = f_mask

 

posted @   皮卡皮卡妞  阅读(3100)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示