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

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

Closed
3 tasks
esconda opened this issue Oct 17, 2018 · 9 comments
Closed
3 tasks
Assignees
Labels
stat:awaiting response from contributor To investigate Looks like a bug. It needs someone to investigate.

Comments

@esconda
Copy link

esconda commented Oct 17, 2018

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).

@gabrieldemarmiesse
Copy link
Contributor

Please 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).

@TimOgden
Copy link

Also having this issue. Are you using a Lambda layer in your Sequential model? I've never had an issue with keras.model.load_model(path) until I made a model that has a Lambda layer.

@GuohongWu
Copy link

Also having this issue. Are you using a Lambda layer in your Sequential model? I've never had an issue with keras.model.load_model(path) until I made a model that has a Lambda layer.

Having exactly the same problem with you! Tensorflow 1.12.0 with tf.keras backend

@jvishnuvardhan
Copy link
Contributor

Is this still an issue? If not close the issue. If you still have this issue, Please provide a code to reproduce the bug. Thanks!

@tdoneal
Copy link

tdoneal commented Apr 10, 2019

Also having this, and my model includes Lambda layers.

I've noticed that when the function "in" the Lambda layer refers to a class method, things don't work nicely. That inner function seems to need to refer to a named, static Python function.

I've also noticed additional oddities, like the functions in question not being able to find imports defined in the same file upon deserialization (load_model).

In general, it seems like support for exotic kinds of Python functions within the Lambda(...) doesn't play very nicely with Keras serialization.

@jvishnuvardhan
Copy link
Contributor

Please fill the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Along with the template, please provide as many details as possible to find the root cause of the issue. It would be great if you can provide a small code to reproduce the error. Thanks!

@jvishnuvardhan
Copy link
Contributor

It looks like you haven't used a template to create this issue. Please resubmit your issue using a template from here. We ask users to use the template because it reduces overall time to resolve a new issue by avoiding extra communication to get to the root of the issue. We will close this issue in lieu of the new one you will create from the template. Thank you for your cooperation.

@ethanfowler
Copy link

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}

@robot010
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting response from contributor To investigate Looks like a bug. It needs someone to investigate.
Projects
None yet
Development

No branches or pull requests

9 participants