autodiff icon indicating copy to clipboard operation
autodiff copied to clipboard

Fix some remainder/truncation duals

Open ryan-williams opened this issue 2 years ago • 1 comments

I could be wrong about these, but:

  • Removed a few places were the % operator was applied to the dx component (that should basically never happen, afaict)
  • Set dx to 0 in a few cases (floor, ceil, round, etc). These functions are flat everywhere they're differentiable, epsilon perturbations will always leave the value unchanged, so the dx component should be wiped out by them, unless I'm mistaken.

I considered adding tests but simple tests would just repeat my assumptions about how the math should work (e.g. asserting dx == 0 in some cases). It would be nice to add tests that perturb values by EPSILON, and verify that the empirical and theoretical gradients match. I'm open to trying that out, but maybe as a follow-on PR, as ≈all of the operations warrant that, not just the ones I've touched here.

ryan-williams avatar Aug 09 '23 13:08 ryan-williams

I think you are right! Thank you for the PR. It would be awesome to have more tests here!

elrnv avatar Aug 14 '23 05:08 elrnv