Skip to content

Fix: UpSampling2D bilinear channels_first bug #21439

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

Conversation

tristandb8
Copy link

The current approach transforms the tensor to channels_last, before passing it in ops.image.resize, which has been defined as channels_first. This creates a bug, a passed in tensor [16, 3, 224, 224] will return as shape [16, 448, 224, 448] instead of [16, 3, 448, 448]. Setting the data_format as the expected channels_last fixes that issue.
Closes #21401

The current approach transforms the tensor to channels_last, before passing it in ops.image.resize, which has been defined as channels_first. This creates a bug, a passed in tensor [16, 3, 224, 224] will return as shape [16, 448, 224, 448] instead of [16, 3, 448, 448]. Setting the data_format as the expected channels_last fixes that issue.
Closes keras-team#21401
Copy link

google-cla bot commented Jun 30, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@codecov-commenter
Copy link

codecov-commenter commented Jun 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.72%. Comparing base (713172a) to head (c8d948b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #21439   +/-   ##
=======================================
  Coverage   82.72%   82.72%           
=======================================
  Files         565      565           
  Lines       55247    55247           
  Branches     8613     8613           
=======================================
  Hits        45702    45702           
  Misses       7433     7433           
  Partials     2112     2112           
Flag Coverage Δ
keras 82.53% <100.00%> (ø)
keras-jax 63.34% <100.00%> (ø)
keras-numpy 58.52% <100.00%> (+<0.01%) ⬆️
keras-openvino 33.77% <0.00%> (ø)
keras-tensorflow 63.75% <100.00%> (ø)
keras-torch 63.35% <100.00%> (ø)

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.

@gbaned
Copy link
Collaborator

gbaned commented Jul 2, 2025

Hi @tristandb8 Can you please sign CLA? Thank you!

Copy link
Collaborator

@fchollet fchollet 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 PR!

  • Please add a unit test for this change.
  • Please run the code formatter.

@tristandb8
Copy link
Author

There was an issue with CLA, the author email it was asking me to verify doesn't exist. I made a new PR (#21456) instead, which passes the CLA and includes the required unit tests.

@tristandb8 tristandb8 closed this Jul 6, 2025
@github-project-automation github-project-automation bot moved this from Assigned Reviewer to Closed/Rejected in PR Queue Jul 6, 2025
@tristandb8 tristandb8 deleted the fix/upsampling2d_bilinear_channelfirst_bug branch July 6, 2025 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Closed/Rejected
Development

Successfully merging this pull request may close these issues.

keras.layers.UpSampling2D bilinear channel first bug
4 participants