-
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
Add Export for TF backend #692
Merged
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
88e9b30
Add saved model test
nkovela1 dfd404f
Merge remote-tracking branch 'refs/remotes/origin/main'
nkovela1 19b0e39
Add TF tracking attribute
nkovela1 0be8fcc
Add tests for functional and subclassed
nkovela1 8908273
Fix saving trackables
nkovela1 0418c60
Fix test assertions
nkovela1 82c3af1
Fix formatting
nkovela1 6c8731d
Add comments for attribute tracking
nkovela1 ac35c30
Merge branch 'keras-team:main' into main
nkovela1 d341600
Merge remote-tracking branch 'refs/remotes/origin/main'
nkovela1 8c1d954
Change saved model test description
nkovela1 9751d02
Add backend conditional for attribute
nkovela1 c1391cb
Change package name
nkovela1 1e7df16
Change epoch nums
nkovela1 51410fe
Revert epochs
nkovela1 1f11c1a
Add set verbose logging utility and debug callback tests
nkovela1 e93a4a6
Fix formatting
nkovela1 99301e1
Sync with main repo
nkovela1 a6eda55
Merge remote-tracking branch 'refs/remotes/origin/main'
nkovela1 2902b72
Merge remote-tracking branch 'refs/remotes/origin/main'
nkovela1 49b74b8
Merge remote-tracking branch 'refs/remotes/origin/main'
nkovela1 1f446c0
Initial port of model export
nkovela1 adbc885
Fix imports
nkovela1 ede9bd7
Add save spec methods to TF layer
nkovela1 d4f2b1a
Add export function to Keras Core base model
nkovela1 766b9f6
Downgrade naming error to warning and debug TF variable collections c…
nkovela1 b6990f8
Simplify weight reloading
nkovela1 316fdc7
Fix formatting, add TODOs
nkovela1 02df6af
Unify tf_utils under backend/tensorflow
nkovela1 8f3f3c9
Fix docstring and import
nkovela1 82bf3a3
Fix module utils import
nkovela1 9fdb0dc
Fix lookup layers export and add test
nkovela1 796b466
Change naming to TFSMLayer
nkovela1 db80dc9
Remove parameterized
nkovela1 4861175
Comment out failing test
nkovela1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add save spec methods to TF layer
- Loading branch information
commit ede9bd71a77e40c334f44e6fc047c4d19dd3a14e
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import tensorflow as tf | ||
|
||
def get_tensor_spec(t, dynamic_batch=False, name=None): | ||
"""Returns a `TensorSpec` given a single `Tensor` or `TensorSpec`.""" | ||
if isinstance(t, tf.TypeSpec): | ||
spec = t | ||
elif isinstance(tensor, tf.__internal__.CompositeTensor): | ||
# Check for ExtensionTypes | ||
spec = t._type_spec | ||
elif hasattr(t, "shape") and hasattr(t, "dtype"): | ||
spec = tf.TensorSpec(shape=t.shape, dtype=t.dtype, name=name) | ||
else: | ||
return None # Allow non-Tensors to pass through. | ||
|
||
if not dynamic_batch: | ||
return spec | ||
|
||
shape = spec.shape | ||
if shape.rank is None or shape.rank == 0: | ||
return spec | ||
|
||
shape_list = shape.as_list() | ||
shape_list[0] = None | ||
shape = tf.TensorShape(shape_list) | ||
spec._shape = shape | ||
return spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should only have one tf utils file. We already have
utils/tf_utils.py
. We need to consolidate in one of them. I thinkbackend/tf_utils.py
is probably the best choice: 1. explicit name (in general avoidutils.py
it's too generic), 2. confined to the TF backend folder.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.
Good idea, I've merged them into
tf_utils.py
under the TF backend folder.