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

NotImplementedError: Layers with arguments in __init__ must override get_config. #36

Open
connormeaton opened this issue Jan 15, 2020 · 1 comment

Comments

@connormeaton
Copy link

Hello, I am trying to save a model built exactly from your code example. However, I get the below error. Any advice?

`---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
in ()
----> 1 tf.keras.models.save_model( model, 'model', overwrite=True, include_optimizer=True )
2

5 frames
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/save.py in save_model(model, filepath, overwrite, include_optimizer, save_format, signatures)
107 'or using save_weights.')
108 hdf5_format.save_model_to_hdf5(
--> 109 model, filepath, overwrite, include_optimizer)
110 else:
111 saved_model_save.save(model, filepath, overwrite, include_optimizer,

/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/hdf5_format.py in save_model_to_hdf5(model, filepath, overwrite, include_optimizer)
91
92 try:
---> 93 model_metadata = saving_utils.model_metadata(model, include_optimizer)
94 for k, v in model_metadata.items():
95 if isinstance(v, (dict, list, tuple)):

/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/saving_utils.py in model_metadata(model, include_optimizer, require_config)
158 except NotImplementedError as e:
159 if require_config:
--> 160 raise e
161
162 metadata = dict(

/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/saving_utils.py in model_metadata(model, include_optimizer, require_config)
155 model_config = {'class_name': model.class.name}
156 try:
--> 157 model_config['config'] = model.get_config()
158 except NotImplementedError as e:
159 if require_config:

/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/network.py in get_config(self)
884 for layer in self.layers: # From the earliest layers on.
885 layer_class_name = layer.class.name
--> 886 layer_config = layer.get_config()
887
888 filtered_inbound_nodes = []

/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/base_layer.py in get_config(self)
578 # or that get_config has been overridden:
579 if len(extra_args) > 1 and hasattr(self.get_config, '_is_default'):
--> 580 raise NotImplementedError('Layers with arguments in __init__ must '
581 'override get_config.')
582 # TODO(reedwm): Handle serializing self._dtype_policy.

NotImplementedError: Layers with arguments in __init__ must override get_config.`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants