剔除tensor数组中的异常数值

假设A为tensor数组
在网络训练过程中,求tensor数组的平均值时,可以使用torch.nanmean(A)来剔除数组中的异常数值或无穷大数值。这个函数等价于torch.mean(A[~A.isnan()])

猜你喜欢

转载自blog.csdn.net/qq_41598072/article/details/130346047