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
load_model: __init__() got an unexpected keyword argument 'name' #8956
Comments
When I make a class inherited keras.model.Model, I met the same problem. |
Adding **kwargs to the init method doesn't solve for me. My custom layer's init method has other arguments (seq and char_len), after adding **kwargs solves the 'name' error but now I get error "TypeError: init() missing 2 required positional arguments: 'seq' and 'char_len'" I'm using keras v2.2.2 |
If you use custom args for your model, then implement |
@liyuan1234 @eIGato @sander314 |
@zrx1046 show your code please. |
@zrx1046 add a get_config function like this
|
I have the similar error as: Can someone help? |
@Aisha1214 load the model using: instead of: |
i am using tensorflow version 1.11.0 some reason i am getting this issue even after using from tensorflow.keras.models import load_model
|
Hello, I met the same issue, Could you please share your solution? Thanks! |
Hi, Could you please share your solution? I met the same issue. Thanks |
In running and adapting this code I came across an issue.
https://people.xiph.org/~jm/demo/rnnoise/
Loading the saved model with
model = load_model("model.hdf5", custom_objects={'WeightClip': WeightClip,'mycost':mycost,'msse':msse})
Keras gives the error
init() got an unexpected keyword argument 'name'
This can be tracked down to /utils/generic_utils.py
Particularly config['config']['name'] exists, while the class (the constraint WeightClip class) does not expect such an argument. This was both rather un-intuitive behaviour of the serializer and confusing for an error message.
Simply adding **kwargs to my class's init function fixed the issue for me.
Below is my best attempt at patching the issue such that Keras accepts the class without **kwargs and without breaking backward compatibility for anyone who does want to use the name field for some reason, but given my limited python skills I expect there is a better way.
The text was updated successfully, but these errors were encountered: