keras-team / keras-core

A multi-backend implementation of the Keras API, with support for TensorFlow, JAX, and PyTorch.
Apache License 2.0
1.27k stars 115 forks source link

Fix the inconsistency in `affine_transform` between numpy and jax #926

Closed james77777778 closed 10 months ago

james77777778 commented 10 months ago

This PR resolves the inconsistency in affine_transform between numpy and jax due to the unfixed scipy.ndimage.map_coordinates.

Previous:

References:

Let's check if the CI is functioning as expected.

EDITED: I have found that using interpolation="nearest" leads to test failures in torch and jax. The root cause might be differences in the output indices, resulting in significant error in image values.

Currently, I have no idea how to fix it, so self.skipTest has been added.

EDITED2: After the change, I encountered a failure in nn.moments in jax. atol and rtol have been increased to 1e-5 to pass the test.

I believe that the failure now only occurs in discretization_test.py.

codecov[bot] commented 10 months ago

Codecov Report

Patch coverage has no change and project coverage change: +5.29% :tada:

Comparison is base (cbc2e47) 66.78% compared to head (318763f) 72.07%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #926 +/- ## ========================================== + Coverage 66.78% 72.07% +5.29% ========================================== Files 318 318 Lines 28666 28666 Branches 5464 5464 ========================================== + Hits 19145 20662 +1517 + Misses 8180 6633 -1547 - Partials 1341 1371 +30 ``` | [Flag](https://app.codecov.io/gh/keras-team/keras-core/pull/926/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | Coverage Δ | | |---|---|---| | [keras_core](https://app.codecov.io/gh/keras-team/keras-core/pull/926/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `72.02% <0.00%> (+5.24%)` | :arrow_up: | | [keras_core-jax](https://app.codecov.io/gh/keras-team/keras-core/pull/926/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `67.10% <0.00%> (?)` | | | [keras_core-tensorflow](https://app.codecov.io/gh/keras-team/keras-core/pull/926/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `66.78% <0.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files Changed](https://app.codecov.io/gh/keras-team/keras-core/pull/926?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | Coverage Δ | | |---|---|---| | [keras\_core/backend/jax/image.py](https://app.codecov.io/gh/keras-team/keras-core/pull/926?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team#diff-a2VyYXNfY29yZS9iYWNrZW5kL2pheC9pbWFnZS5weQ==) | `76.00% <0.00%> (+76.00%)` | :arrow_up: | | [keras\_core/backend/numpy/image.py](https://app.codecov.io/gh/keras-team/keras-core/pull/926?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team#diff-a2VyYXNfY29yZS9iYWNrZW5kL251bXB5L2ltYWdlLnB5) | `0.00% <0.00%> (ø)` | | ... and [46 files with indirect coverage changes](https://app.codecov.io/gh/keras-team/keras-core/pull/926/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.