question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot convert Keras saved model

See original GitHub issue

System information

  • Ubuntu 18.04 WSL
  • tensorflow 2.5.0

Describe the problem

Model convertion using tensorflowjs_converter --input_format=keras_saved_model ./model_autokeras ./converted_model throws following error:

RuntimeError: Unable to restore a layer of class Custom>MultiCategoryEncoding. Layers of class Custom>MultiCategoryEncoding require that the class be provided to the model loading code, either by registering the class using @keras.utils.register_keras_serializable on the class def and including that file in your program, or by passing the class in a keras.utils.CustomObjectScope that wraps this load call.

My model has been generated using Autokeras StructuredDataRegressor.

Provide the exact sequence of commands / steps that you executed before running into the problem

This can be reproduced by following this tutorial: https://autokeras.com/tutorial/structured_data_regression/

And then run tensorflowjs_converter --input_format=keras_saved_model ./model_autokeras ./converted_model

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
wingman-jr-addoncommented, Sep 28, 2021

Looks like you might have a custom layer that is not supported “natively” in Tensorflow.js. Have you tried changing the output format to --output_format=tfjs_graph_model?

0reactions
google-ml-butler[bot]commented, Oct 12, 2021

Are you satisfied with the resolution of your issue? Yes No

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading the saved models from tf.keras in different versions ...
Is there any way to either convert the models from the format of the new version of tf to an older version so...
Read more >
Save and load Keras models | TensorFlow Core
When saving the model and its layers, the SavedModel format stores the class name, call function, losses, and weights (and the config, if ......
Read more >
Cannot convert keras.layers.Embedding · Issue #44197 - GitHub
Hi, I found simple model with keras.layers.Embedding cannot be converted to tflite. I built my model with python API and then tried to ......
Read more >
Model saving & serialization APIs - Keras
Keras SavedModel uses tf.saved_model.save to save the model and all trackable objects attached to the model (e.g. layers and variables). The model config, ......
Read more >
How to convert Keras* H5 model to an Intermediate ... - Intel
Install dependencies: ; Load the model using TensorFlow* 2 and ; serialize it in the SavedModel format. ; Change directory to <INSTALL_DIR>/deployment_tools/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found