Skip to content
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

Hessian of perturbation function yields zero matrix #68

Open
adamhaber opened this issue Sep 22, 2022 · 0 comments
Open

Hessian of perturbation function yields zero matrix #68

adamhaber opened this issue Sep 22, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@adamhaber
Copy link
Contributor

Describe the bug

Computing the Hessian (as discussed in #60) yields the zero matrix.

To Reproduce

See https://github.com/adamhaber/snn-sound-localization/blob/compute-hessians/research/Compute%20Hessians.ipynb
Specifically, the relevant part is what happens in cells 15+; the function calc_acc computes the mean squared difference between the outputs of the original, trained network and a perturbed version of it (currently only W2 is perturbed, since it's smaller).

This is obviously not the most efficient way to do this - I just wanted to quickly get a feel for the Hessians, but it's always zero.

At first I thought that this might be caused by the surrogate gradients, but I get all-zero Hessians even when I change
spike_fn = SurrGradSpike.apply
to
spike_fn = nn.Sigmoid()
(see cell 9).

I've also changed the dtype to float64 in case these are underflows, but this didn't help, either.

Expected behavior

A non-zero matrix of second derivatives (eventually we'll be interested in torch.autograd.functional.hessian(calc_acc, torch.zeros_like(p)).

I don't have much experience with PyTorch (has anyone ported this to jax? if so I'd be happy to try it there) - what am I missing?

@adamhaber adamhaber added the bug Something isn't working label Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant