np.where和torch.where的使用区别

两者都是三个输入参数,第一个是判断条件,第二个是符合条件的设置值,第三个是不满足条件的设置值。

区别在于,torch要将设置值全部改为Tensor类型的

mask_true = torch.where(torch.isnan(y_true), torch.full_like(y_true, 0), torch.full_like(y_true, 1))
mask_true = np.where(np.isnan(y_true), 0, 1)
发布了38 篇原创文章 · 获赞 98 · 访问量 36万+

猜你喜欢

转载自blog.csdn.net/xijuezhu8128/article/details/86590562
今日推荐