shlogg · Early preview
Super Kai (Kazuya Ito) @superkai_kazuya

Torch Nan And Inf Replacement With Nan_to_num()

Torch.nan and torch.inf explained. Learn how to replace NaNs and infinities with zeros or specified values using nan_to_num() function.

Buy Me a Coffee☕
*My post explains torch.nan and torch.inf.
nan_to_num() can get the 0D or more D tensor of zero or more elements, replacing zero or more NaNs(Not a Numbers), positive infinities and negative infinities with zero or more zeros, the greatest finities and the least finities respectively(Default) or specified values from the 0D or more D tensor of zero or more elements as shown below:
*Memos:

nan_to_num() can be used with torch or a tensor.
The 1st argument(input) with torch or using a tensor(Required-Type:tensor of int, float, complex or bool).
The 2nd argument with torch or th...