Unknown initializer: GlorotUniform when loading Keras model
See original GitHub issueTensorFlow.js version
Version 0.13.2
Browser version
Google Chrome Version 69.0.3497.100 (64-bit)
Describe the problem or feature request
I am currently trying to load a convolutional neural network model from Keras (version 2.2.4) that has been converted using the tensorflow_converter utility (pip tensorflowjs version 0.6.4).
Upon loading the model, I am met with the following error:
Uncaught (in promise) Error: Unknown initializer: GlorotUniform. This may be due to one of the following reasons:
1. The initializer is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
2. The custom initializer is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().
at new t (tfjs@0.13.2:2)
at deserializeKerasObject (tfjs@0.13.2:2)
at deserializeInitializer (tfjs@0.13.2:2)
at getInitializer (tfjs@0.13.2:2)
at t [as constructor] (tfjs@0.13.2:2)
at new t (tfjs@0.13.2:2)
at e.fromConfig (tfjs@0.13.2:2)
at deserializeKerasObject (tfjs@0.13.2:2)
at deserialize (tfjs@0.13.2:2)
at i (tfjs@0.13.2:2)
However, the GlorotUniform initializer is part of tensorflowjs (https://js.tensorflow.org/api/0.13.0/#initializers.glorotUniform).
I have attached the model.json
file that I’d like to load to this issue:
model.zip
Code to reproduce the bug / link to feature request
const model = tf.loadModel("./model.json");
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
Unknown initializer: GlorotUniform when loading Keras model
I ran into the same issue. After changing: from tensorflow import keras. to: import keras. life is once again worth living.
Read more >Unknown initializer: GlorotUniform when loading Keras model
I trained my CNN (VGG) through google colab and generated .h5 file. Now problem is, I can predict my output successfully through google ......
Read more >Unknown initializer: GlorotUniform when loading Keras model
It seems like a serialization bug in keras. If you wrap your load_model with the below CustomObjectScope method, it would work fine. For...
Read more >GlorotUniform when using models.model_from_json(json)
[Solved] ValueError: Unknown initializer: GlorotUniform when ... Hi there, if you are trying to load tensorflow neural network model from ...
Read more >tf.keras.initializers.GlorotUniform | TensorFlow v2.11.0
The Glorot uniform initializer, also called Xavier uniform initializer. ... covering diffusion models with KerasCV, on-device ML, and more.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the problem using this command: loaded_model = model_from_json(loaded_model_json)
but when I add (tf.keras.models.): loaded_model = tf.keras.models.model_from_json(loaded_model_json)
it works just fine
Try adding the following in the model load function call.
custom_objects={“GlorotUniform”: tf.keras.initializers.glorot_uniform}