You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An issue with denormals in the phase loss calculation is causing the torch.angle function to return NaN values, as discussed here. A possible solution is to replace values close to zero with a certain threshold.
defreplace_denormals(x: Tensor, threshold: float=1e-10) ->Tensor:
"""Replace numbers close to zero to avoid NaNs in `angle`"""y=x.clone()
y[torch.abs(x) <threshold] =thresholdreturnydefangle(x: Tensor) ->Tensor:
"""Calculates the angle of a complex or real tensor"""iftorch.is_complex(x):
x_real=x.realx_imag=x.imagelse:
x_real=xx_imag=torch.zeros_like(x_real)
x_real=replace_denormals(x_real)
x_imag=replace_denormals(x_imag)
returntorch.atan2(x_imag, x_real)
The text was updated successfully, but these errors were encountered:
An issue with denormals in the phase loss calculation is causing the torch.angle function to return NaN values, as discussed here. A possible solution is to replace values close to zero with a certain threshold.
The text was updated successfully, but these errors were encountered: