pytorch判断tensor是否有脏数据NaN
时间:2019-08-12 22:41:05
收藏:0
阅读:1545
You can always leverage the fact that nan != nan:
>>> x = torch.tensor([1, 2, np.nan]) tensor([ 1., 2., nan.]) >>> x != x tensor([ 0, 0, 1], dtype=torch.uint8)
With pytorch 0.4 there is also torch.isnan:
>>> torch.isnan(x)
tensor([ 0, 0, 1], dtype=torch.uint8)
原文:https://www.cnblogs.com/xiaoaoran/p/11342728.html
评论(0)