-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
norms should delegate to the backend where possible #6
Comments
With an example to demonstrate the issue: import torch
import eagerpy
a = torch.tensor([0.], requires_grad=True)
torch.norm(a, p=2).backward()
print(a.grad)
eagerpy.astensor(a).norms.l2().raw.backward()
print(a.grad)
|
Hi @mglisse, thanks for request and the example code. |
Hi, thanks for the reply. I use eagerpy so I can write the code only once and let it work with several frameworks. It is true that currently I mostly experiment with pytorch though. |
Hello,
with a pytorch tensor t, I can call
t.norm(p, dim)
. This gives a similar result to eagerpy'slp
, but makes a huge difference when it comes to the gradient. Pytorch has this feature where deriving sqrt in 0 gives infinity (mathematically sensible), which often yields a gradient of NaN. However, special functions likenorm
are handled specially, similarly toabs
, and return a suitable subgradient (0).Could you please make l2/lp/... call
norm
for the pytorch backend?The text was updated successfully, but these errors were encountered: