-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeError: Function 'SqrtBackward' returned nan values in its 0th output. #69
Comments
Somehow switching from vgg to alexnet solved this issue. |
Having the same problem using alexnet. Solved by adding epsilon under the sqrt. |
Hi @MartinPernus , do you mean you added an epsilon within the sqrt calculation? I am having the same error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
i wanted to ask if its possible to add the epsilon under the sqrt in the norm function instead of adding it under the fraction because I think for my use case some sqrt are 0 and therefore the gradient returns nan.
def normalize_tensor(in_feat,eps=1e-10):
norm_factor = torch.sqrt(torch.sum(in_feat**2,dim=1,keepdim=True))
return in_feat/(norm_factor+eps)
The text was updated successfully, but these errors were encountered: