Skip to content

Conversation

israelg99
Copy link

@israelg99 israelg99 commented Dec 17, 2018

If the exported tf.keras model has any tf operations or Lambda layers that use tf internally loading the model will fail with the error tf is not defined.
To fix that it is important to load tf as a custom object when loading a keras model like that - cusotm_objects={'tf': tf).

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@israelg99
Copy link
Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@ymodak ymodak self-assigned this Dec 17, 2018
@ymodak ymodak requested a review from gargn December 17, 2018 17:58
@ymodak ymodak added the awaiting review Pull request awaiting review label Dec 17, 2018
@dksb dksb added the size:XS CL Change Size: Extra Small label Dec 22, 2018
@ymodak
Copy link
Contributor

ymodak commented Jan 8, 2019

@gargn Can you please take a look? Thanks!

@andrehentz andrehentz added the comp:lite TF Lite related issues label Jan 11, 2019
input_shapes=None,
output_arrays=None):
output_arrays=None,
custom_objects=None):
Copy link

Choose a reason for hiding this comment

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

Instead of adding custom_objects is it possible to add **kwargs to from_keras_model_file()?. See below for rest of the comments.

_keras.backend.clear_session()
_keras.backend.set_learning_phase(False)
keras_model = _keras.models.load_model(model_file)
keras_model = _keras.models.load_model(model_file, custom_objects=custom_objects)
Copy link

Choose a reason for hiding this comment

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

And let this call be _keras.models.load_model(model_file, **kwargs).
This is a way to make the API from_keras_model_file() somewhat future proof w.r.t underlying Keras load_model() API change?.

@tensorflowbutler tensorflowbutler removed the awaiting review Pull request awaiting review label Mar 13, 2019
@Hazarapet
Copy link

Hazarapet commented Mar 18, 2019

Any news from this? I see pull request is not merged yet.

@gargn
Copy link

gargn commented Apr 22, 2019

This functionality has been added by 09deaeb.

@gargn gargn closed this Apr 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes comp:lite TF Lite related issues size:XS CL Change Size: Extra Small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants