-
Notifications
You must be signed in to change notification settings - Fork 118
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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:
@fchollet Thank you for the review. The PR has been updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
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
usestf.function
with the parameterreduce_retracing
(e.g., here), but thereduce_retracing
has been introduced since TF 2.9. This PR is able to handle this issue with adaptive keyword arguments.