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

Convert RandomTranslation to the backend-agnostic implementation #572

Merged
merged 3 commits into from
Jul 22, 2023

Conversation

james77777778
Copy link
Contributor

Related to keras-team/keras#18442

Tests all passed in my local env

@james77777778 james77777778 changed the title Converting RandomTranslation to the backend-agnostic implementation Convert RandomTranslation to the backend-agnostic implementation Jul 21, 2023
Copy link
Member

@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. It's looking good! Please make sure we have enough test coverage, I think the current unit tests are pretty weak. You can use pytest-cov to check which parts of the code are covered.

self.width_lower, self.width_upper = self._set_factor(
width_factor, "width_factor"
)
self._check_fill_mode_and_interpolation(fill_mode, interpolation)
Copy link
Member

Choose a reason for hiding this comment

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

You can inline this logic here, no need for a separate method since it's only used 1x

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@james77777778
Copy link
Contributor Author

I have added some tests including:

  • raise ValueError with bad factors
  • training=False behavior
  • channels_first & channels_last

Now the coverage becomes 100%

Name                                                    Stmts   Miss  Cover
---------------------------------------------------------------------------
keras_core/layers/preprocessing/random_translation.py      74      0   100%

Copy link
Member

@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.

Excellent -- thank you for the contribution!

@fchollet fchollet merged commit cd23e66 into keras-team:main Jul 22, 2023
6 checks passed
@james77777778 james77777778 deleted the update-randomtranslation branch July 25, 2023 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants