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.

Keras load_model command error : 'NoneType' object has no attribute 'get'

See original GitHub issue

Please make sure that the boxes below are checked before you submit your issue. If your issue is an implementation question, please ask your question on StackOverflow or on the Keras Slack channel instead of opening a GitHub issue.

Thank you!

  • Check that you are up-to-date with the master branch of Keras. You can update with: pip install git+git://github.com/keras-team/keras.git --upgrade --no-deps

  • Check that your version of TensorFlow is up-to-date. The installation instructions can be found here.

  • Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

11reactions
ethanfowlercommented, May 29, 2019

In case it helps anyone else having this issue: my solution was to use the custom_objects argument of keras.model.load_model to provide a dictionary of custom objects/functions, including the function used within my Lambda layer. Model loads fine now.

In model definition:

x = tf.keras.layers.Lambda(self.lamba_function)(x)

Later, when loading the same model:

keras.models.load_model(filename, custom_objects={'lamba_function': self.lamba_function}
3reactions
robot010commented, Jul 12, 2019

I’m having this issue after updating keras to 2.2.4. I have a python lambda function at my loss function, and using “load_model” with argument “custom_objects” won’t help. I was wondering if there is any other ways to deal with this issue besides only saving weights (discard the model structure).

Read more comments on GitHub >

github_iconTop Results From Across the Web

'NoneType' object has no attribute 'get' ) while loading saved ...
This error can be caused by having custom logic in your model, and not providing the custom logic in the custom_objects arguments when ......
Read more >
How to Save and Load Your Keras Deep Learning Model
Keras is a simple and powerful Python library for deep learning. ... “AttributeError: 'KerasClassifier' object has no attribute 'save'”.
Read more >
Error AttributeError: 'NoneType' object has no attribute ...
My model is as follows: embed_dim = 16 vocab_size = vocab.num_words np_text_tensor = np.array(text_tensor_train) print(np_text_tensor.shape)
Read more >
Saving and Loading Tensorflow Model Results in Keras Error
I get the following error message. File "sampleModel.py", line 342, in <module> model = tf.keras.models.
Read more >
'sequential' object has no attribute 'score' - You.com - You.com
tensorflow\python\keras\engine\sequential.py:455: UserWarning: model.predict_classes() is deprecated and will be removed after 2021-01-01. Please use instead:* ...
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