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

Hacky fix for dictionary output with tf 2.14 #933

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

mattdangerw
Copy link
Member

See keras-team/keras#18399 for more info. And other workaround we could consider.

@codecov
Copy link

codecov bot commented Sep 20, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +7.00% 🎉

Comparison is base (a465816) 76.82% compared to head (55e9c46) 83.83%.
Report is 49 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     keras-team/keras-core#933      +/-   ##
==========================================
+ Coverage   76.82%   83.83%   +7.00%     
==========================================
  Files         329      318      -11     
  Lines       31427    28743    -2684     
  Branches     6112     5491     -621     
==========================================
- Hits        24144    24096      -48     
+ Misses       5719     3141    -2578     
+ Partials     1564     1506      -58     
Flag Coverage Δ
keras_core 83.72% <66.66%> (+6.99%) ⬆️
keras_core-jax 67.16% <16.66%> (?)
keras_core-numpy 60.63% <16.66%> (?)
keras_core-tensorflow 66.97% <66.66%> (?)
keras_core-torch 69.22% <16.66%> (?)

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

Files Changed Coverage Δ
keras_core/ops/function.py 92.68% <100.00%> (+0.27%) ⬆️

... and 49 files with indirect coverage changes

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

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!

@@ -46,10 +47,20 @@ class Function(Operation):
def __init__(self, inputs, outputs, name=None):
super().__init__(name=name)

if backend() == "tensorflow":
Copy link
Member

Choose a reason for hiding this comment

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

Can we do this in keras_core/backend/tensorflow/layer.py::TFLayer.__init__ instead?

Copy link
Member Author

@mattdangerw mattdangerw Sep 20, 2023

Choose a reason for hiding this comment

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

I don't think so, because we can't turn off tf auto tracking overall for functional models. We only want to turn it off for the input/output structs here to avoid the tf bug. Essentially we need a way to run a hook inside Function.__init__.

The nice way to avoid all this would be to use Tracker for our tf tracking. This could save a lot of bugs I think, but is more of an effort. https://github.com/keras-team/keras-core/issues/934#issuecomment-1728464445

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could just not depend on AutoTrackable (just Trackable) and then manually track everything according to our own Tracker.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think this would take some work, but really improve the overall state if we did.

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.

LGTM

@@ -46,10 +47,20 @@ class Function(Operation):
def __init__(self, inputs, outputs, name=None):
super().__init__(name=name)

if backend() == "tensorflow":
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could just not depend on AutoTrackable (just Trackable) and then manually track everything according to our own Tracker.

@fchollet fchollet merged commit aa270a2 into keras-team:main Sep 20, 2023
8 checks passed
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