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

Improve TensorFlowTrainer compatibility for TF<2.9 #598

Merged
merged 3 commits into from
Jul 26, 2023

Conversation

taehoonlee
Copy link
Collaborator

@taehoonlee taehoonlee commented Jul 25, 2023

I'm not sure if support for TensorFlow older versions is intended, but it would be nice to take care of backward compatability because not everyone uses the latest TensorFlow. The current TensorFlowTrainer uses tf.function with the parameter reduce_retracing (e.g., here), but the reduce_retracing has been introduced since TF 2.9. This PR is able to handle this issue with adaptive keyword arguments.

Copy link
Contributor

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

@@ -22,6 +24,11 @@ def __init__(self):
self.test_function = None
self.predict_function = None

if Version(tf.__version__) >= Version('2.9.0'):
self.support_reduce_retracing = True
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make it a private attribute, self._supports_reduce_retracing

reduce_retracing=True,
)
kwargs = {'jit_compile': self.jit_compile}
if self.support_reduce_retracing is True:
Copy link
Contributor

Choose a reason for hiding this comment

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

Just if self._supports_reduce_retracing:

@taehoonlee
Copy link
Collaborator Author

@fchollet Thank you for the review. The PR has been updated.

Copy link
Contributor

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

LGTM, thanks

@fchollet fchollet merged commit 28c29e7 into keras-team:main Jul 26, 2023
@taehoonlee taehoonlee deleted the improve_compatibility branch July 26, 2023 08:50
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