Repository navigation
Preserve coordinate gradients at integer interpolation points - #126
sylvesterkaczmarek wants to merge 2 commits into
Conversation
|
@claudiofantacci Thanks for the approvals on #126 and #131. #125 also retains an approval, and all three current heads are mergeable with green public checks; #126 and #131 additionally have successful Copybara import and Google internal feedback. I am grouping this here rather than pinging all three PRs separately. Could you take these through the remaining maintainer merge step, or let me know if there is another gate I should address? |
|
I'm looking why this isn't going through. |
|
Ok back on track! I hope this goes trhough quickly :D |
| @@ -0,0 +1,89 @@ | |||
| # Copyright 2021 DeepMind Technologies Limited. All Rights Reserved. | |||
There was a problem hiding this comment.
I though I already left this comment...? Can you please move these tests under https://github.com/google-deepmind/dm_pix/blob/master/dm_pix/_src/interpolation_test.py please?
|
Moved all the new interpolation-gradient regressions into the existing Validated on macOS arm64, Python 3.12 and JAX 0.11.2 (CPU): |
Summary
Use
floor(coordinate) + 1for the upper interpolation neighbour instead ofceil(coordinate). At integer coordinates, both neighbours currently collapse onto the same sample and the coordinate derivative becomes zero. This is incorrect even for an affine ramp, which is differentiable there: interpolating[0, .25, .5, .75, 1]at coordinate1returns derivative0instead of.25.The same defect removes translation gradients from identity-initialized
affine_transformcalls. The one-line change preserves finite sampled values and existing boundary clipping while retaining the adjacent sample needed by the derivative.Validation
Python 3.12.11, JAX 0.11.2, NumPy 2.5.3 on macOS arm64, CPU:
ebaab9b. Coverage includes 1D/2D/3D ramps, flattened inputs, nearest/constant boundaries, eager/JIT reverse-mode gradients, JVPs, identity affine transforms, and gradients with respect to pixel values.python -m pytest -q -n 2 dm_pix: 1,346 passed, 99 skipped.git diff --checkpass. Pylint has only the same repository-configuration and existing source line-length findings as the unchanged base, with no new code findings.GPU/TPU execution and documentation builds were not run.