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

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 @ 2021-02-22 09:43  皮卡皮卡妞  阅读(3087)  评论(0编辑  收藏  举报