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

Error while importing a Keras Model with a TFHub layer #3052

Open
guidiandrea opened this issue Aug 31, 2020 · 5 comments
Open

Error while importing a Keras Model with a TFHub layer #3052

guidiandrea opened this issue Aug 31, 2020 · 5 comments
Assignees

Comments

@guidiandrea
Copy link

Hello,

I tried importing a Keras model saved in h5 format with the Model.load_keras API, but I got the following error:
Unknown layer: KerasLayer

Which obviously refers to the tensorflow-hub layer. Does this mean that tfhub models can't be used with bigDL?

@hkvision
Copy link
Contributor

hkvision commented Sep 1, 2020

Can you provide with more error message and some code segments?

@guidiandrea
Copy link
Author

A minimal working example:

import tensorflow as tf
import tensorflow_hub as hub
hub_layer = hub.KerasLayer("https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1", output_shape=[20],
                           input_shape=[], dtype=tf.string)
model = tf.compat.v1.keras.Sequential()
model.add(hub_layer)
model.summary()

model.save("text.h5",save_format='h5')
#I can't reload the model
bigdl_model = Model.load_keras(hdf5_path="text.h5")

And here you can find the error message I got
image

@hkvision
Copy link
Contributor

hkvision commented Sep 1, 2020

Model.load_keras is only tested on Keras 1.2.2.

@guidiandrea
Copy link
Author

Thank you @hkvision

Do you have other workarounds to load a tfhub model (other APIs which I don't know...)?

@hkvision
Copy link
Contributor

hkvision commented Sep 1, 2020

You can take a look at TFPark in Analytics Zoo. For the support of TF2, we are still working in progress. TFPark supports TF 1.15 and the corresponding tf.keras.

Le-Zheng pushed a commit to Le-Zheng/BigDL that referenced this issue Oct 20, 2021
* remove featuretools from setup.py and docs

* remove redundant import

* change doc in automl readme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants