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

Conv2d derivative issues #30

Closed
joshromoff opened this issue Jan 19, 2020 · 3 comments
Closed

Conv2d derivative issues #30

joshromoff opened this issue Jan 19, 2020 · 3 comments

Comments

@joshromoff
Copy link

It seems like:

grad_weight = conv2d(input, mat, None, module.dilation, module.padding,

only works for certain stride/padding/kernel/dilation combos and can return an incompatible shape with:

grad_weight = grad_weight.view(num_cols, batch,

From my testing, it works when "in + 2 * padding - dilation * (kernel - 1) - 1" is a multiple of the stride, i.e, when there is no rounding down from the floor operation in the forward pass of the conv2d.

@fKunstner
Copy link
Collaborator

Good catch, thanks for the report! 👍

I pushed a fix, it should find its way to a release soon. You can try it by installing from this branch,
pip install git+https://github.com/f-dangel/backpack.git@issue30

f-dangel added a commit that referenced this issue Jan 20, 2020
Conv2d derivative issues #30 - fix
@f-dangel
Copy link
Owner

Thanks for reporting @joshromoff,
does this fix your problem?

@joshromoff
Copy link
Author

yup! that fixed it. thanks!

f-dangel added a commit that referenced this issue Jul 22, 2021
Add `subsampling` argument to `jac_t_mat_prod` and extend tests

Auxiliary:
- Refactor `if N==1: ... elif N==2: ...` patterns in Nd derivatives
- Other refactorings by introducing helpers functions

---

* [REF] Reduce `if N == ...` branches

* [ADD} Prototypes of all `jac_t` derivatives with `subsampling`

* [REF] Reduce if-else branches, test #30 with save_memory

* [REF] Extract shareable parts from if...else

* [FIX] Remove unused import

* [REF] Make cast data type more specific

* [DOC] Reduce redundancy

* [FMT] Remove blank line

* [REF] Make cast data type more specific

* [REF] Specify dtype

* [REF] Specify dtype

* [FMT] Save one line

* [REF] Move test skip helpers, shorten imports
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

3 participants