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

Vmap and backward hook problem #1106

Open
pmzzs opened this issue Jan 19, 2023 · 1 comment
Open

Vmap and backward hook problem #1106

pmzzs opened this issue Jan 19, 2023 · 1 comment

Comments

@pmzzs
Copy link

pmzzs commented Jan 19, 2023

I try to get the gradient of the intermedia layer of model, so I use the backwards hook with functroch.grad to get the gradient of each image. When I used for loop to iterate each image, I successfully obtained 5000 gradients (dataset size). However, when I use vmap to do the same thing, I only get 40 gradients (40 batches in 1 epoch). Is there any way to solve it, or I have to use for loop?

@kshitij12345
Copy link
Collaborator

@pmzzs It would be great if you can share a self-contained reproducer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants