Replaces NaN
, positive infinity, and negative infinity values in input
with the values specified by nan
, posinf
, and neginf
, respectively. By default, NaN
s are replaced with zero, positive infinity is replaced with the greatest finite value representable by input
’s dtype, and negative infinity is replaced with the least finite value representable by input
’s dtype.
>>> x = torch.tensor([float('nan'), float('inf'), -float('inf'), 3.14]) >>> torch.nan_to_num(x) tensor([ 0.0000e+00, 3.4028e+38, -3.4028e+38, 3.1400e+00]) >>> torch.nan_to_num(x, nan=2.0) tensor([ 2.0000e+00, 3.4028e+38, -3.4028e+38, 3.1400e+00]) >>> torch.nan_to_num(x, nan=2.0, posinf=1.0) tensor([ 2.0000e+00, 1.0000e+00, -3.4028e+38, 3.1400e+00])
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4