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

Fixes inconsistent serialization logic for inputs #20993

Merged

Conversation

JyotinderSingh
Copy link
Collaborator

@JyotinderSingh JyotinderSingh commented Mar 6, 2025

Issue

Consider a model where its input property is represented as [[[input_layer_1, 0, 0]]].
When serialized and deserialized, it turns into [[input_layer_1, 0, 0]].

Fix

This change removes the input_tensor un-nesting logic from functional_from_config method which adds special handling for the above case, now the code proceeds with the regular flow irrespective of triply nested input arrays and maintains consistency across serialization round-trips.

@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.45%. Comparing base (eb1f844) to head (8ad7244).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20993      +/-   ##
==========================================
- Coverage   82.45%   82.45%   -0.01%     
==========================================
  Files         562      562              
  Lines       53303    53314      +11     
  Branches     8257     8258       +1     
==========================================
+ Hits        43949    43958       +9     
- Misses       7338     7340       +2     
  Partials     2016     2016              
Flag Coverage Δ
keras 82.26% <ø> (-0.01%) ⬇️
keras-jax 64.03% <ø> (+<0.01%) ⬆️
keras-numpy 58.85% <ø> (+<0.01%) ⬆️
keras-openvino 32.69% <ø> (+<0.01%) ⬆️
keras-tensorflow 64.47% <ø> (-0.01%) ⬇️
keras-torch 64.08% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@hertschuh hertschuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the bug fix!

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Mar 6, 2025
@JyotinderSingh JyotinderSingh changed the title Fixes inconsistent serialization logic Fixes inconsistent serialization logic for inputs Mar 6, 2025
@hertschuh hertschuh merged commit a8ccaf3 into keras-team:master Mar 6, 2025
12 checks passed
@JyotinderSingh JyotinderSingh deleted the serialization-inconsistency branch March 7, 2025 08:56
11happy pushed a commit to 11happy/keras that referenced this pull request Mar 9, 2025
* Removes unnesting logic for input tensors in functional model deserialization flow

* Adds test case for verifying nested input restoration after deserialization

removes unnecessary imports

* fixes imports
Hmm-1224 pushed a commit to Hmm-1224/keras that referenced this pull request Apr 5, 2025
* Removes unnesting logic for input tensors in functional model deserialization flow

* Adds test case for verifying nested input restoration after deserialization

removes unnecessary imports

* fixes imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to pull Ready to be merged into the codebase size:S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants