Solved by ptrblck in post #4 
              
              
                I’m not aware of any other approaches that to make sure these invalid values are filtered out (e.g. via torch.isfinite(input)).