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

Slice serialization #932

Closed gleize closed 10 months ago

gleize commented 10 months ago

Models that contain slicing cannot be serialized because of the missing handling of slices in the (de)serialize_keras_object functions.

Thus a simple functional as this one.

x = inp = Input(...)
...
x = x[:, 1:-1, 1:-1]
...
fn = Functional(inp, x)

could not be serialized.

Now it's possible with this fix.

codecov[bot] commented 10 months ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +3.99% :tada:

Comparison is base (c64de55) 79.73% compared to head (940163d) 83.73%. Report is 35 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #932 +/- ## ========================================== + Coverage 79.73% 83.73% +3.99% ========================================== Files 318 318 Lines 28627 28737 +110 Branches 5447 5489 +42 ========================================== + Hits 22827 24062 +1235 + Misses 4333 3159 -1174 - Partials 1467 1516 +49 ``` | [Flag](https://app.codecov.io/gh/keras-team/keras-core/pull/932/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/932/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `83.63% <100.00%> (+3.96%)` | :arrow_up: | | [keras_core-jax](https://app.codecov.io/gh/keras-team/keras-core/pull/932/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `67.07% <100.00%> (?)` | | | [keras_core-numpy](https://app.codecov.io/gh/keras-team/keras-core/pull/932/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `60.38% <100.00%> (-0.01%)` | :arrow_down: | | [keras_core-tensorflow](https://app.codecov.io/gh/keras-team/keras-core/pull/932/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `66.87% <100.00%> (+0.05%)` | :arrow_up: | | [keras_core-torch](https://app.codecov.io/gh/keras-team/keras-core/pull/932/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `69.14% <100.00%> (-0.08%)` | :arrow_down: | 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/932?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | Coverage Δ | | |---|---|---| | [keras\_core/ops/numpy.py](https://app.codecov.io/gh/keras-team/keras-core/pull/932?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team#diff-a2VyYXNfY29yZS9vcHMvbnVtcHkucHk=) | `94.40% <100.00%> (-0.05%)` | :arrow_down: | | [keras\_core/saving/serialization\_lib.py](https://app.codecov.io/gh/keras-team/keras-core/pull/932?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team#diff-a2VyYXNfY29yZS9zYXZpbmcvc2VyaWFsaXphdGlvbl9saWIucHk=) | `73.77% <100.00%> (+0.37%)` | :arrow_up: | ... and [44 files with indirect coverage changes](https://app.codecov.io/gh/keras-team/keras-core/pull/932/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.