-
Notifications
You must be signed in to change notification settings - Fork 19.4k
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
1.2.2 network not compatible on 2.0.2 #6382
Comments
I have the same problem. Does Keras2 support loading Keras1 model? ----> 1 km.load_model('model.h5')
/Users/angermue/python/keras/keras/models.py in load_model(filepath, custom_objects)
238 raise ValueError('No model found in config file.')
239 model_config = json.loads(model_config.decode('utf-8'))
--> 240 model = model_from_config(model_config, custom_objects=custom_objects)
241
242 # set weights
/Users/angermue/python/keras/keras/models.py in model_from_config(config, custom_objects)
302 'Maybe you meant to use '
303 '`Sequential.from_config(config)`?')
--> 304 return layer_module.deserialize(config, custom_objects=custom_objects)
305
306
/Users/angermue/python/keras/keras/layers/__init__.py in deserialize(config, custom_objects)
52 module_objects=globs,
53 custom_objects=custom_objects,
---> 54 printable_module_name='layer')
/Users/angermue/python/keras/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
138 return cls.from_config(config['config'],
139 custom_objects=dict(list(_GLOBAL_CUSTOM_OBJECTS.items()) +
--> 140 list(custom_objects.items())))
141 return cls.from_config(config['config'])
142 else:
/Users/angermue/python/keras/keras/engine/topology.py in from_config(cls, config, custom_objects)
2414
2415 for layer_data in config['layers']:
-> 2416 process_layer(layer_data)
2417
2418 name = config.get('name')
/Users/angermue/python/keras/keras/engine/topology.py in process_layer(layer_data)
2383 from ..layers import deserialize as deserialize_layer
2384 layer = deserialize_layer(layer_data,
-> 2385 custom_objects=custom_objects)
2386 created_layers[layer_name] = layer
2387
/Users/angermue/python/keras/keras/layers/__init__.py in deserialize(config, custom_objects)
52 module_objects=globs,
53 custom_objects=custom_objects,
---> 54 printable_module_name='layer')
/Users/angermue/python/keras/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
139 custom_objects=dict(list(_GLOBAL_CUSTOM_OBJECTS.items()) +
140 list(custom_objects.items())))
--> 141 return cls.from_config(config['config'])
142 else:
143 # Then `cls` may be a function returning a class.
/Users/angermue/python/keras/keras/engine/topology.py in from_config(cls, config)
1229 A layer instance.
1230 """
-> 1231 return cls(**config)
1232
1233 def count_params(self):
/Users/angermue/python/keras/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
86 warnings.warn('Update your `' + object_name +
87 '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 88 return func(*args, **kwargs)
89 wrapper._legacy_support_signature = inspect.getargspec(func)
90 return wrapper
/Users/angermue/python/keras/keras/layers/convolutional.py in __init__(self, filters, kernel_size, strides, padding, dilation_rate, activation, use_bias, kernel_initializer, bias_initializer, kernel_regularizer, bias_regularizer, activity_regularizer, kernel_constraint, bias_constraint, **kwargs)
328 kernel_constraint=kernel_constraint,
329 bias_constraint=bias_constraint,
--> 330 **kwargs)
331 self.input_spec = InputSpec(ndim=3)
332
/Users/angermue/python/keras/keras/layers/convolutional.py in __init__(self, rank, filters, kernel_size, strides, padding, data_format, dilation_rate, activation, use_bias, kernel_initializer, bias_initializer, kernel_regularizer, bias_regularizer, activity_regularizer, kernel_constraint, bias_constraint, **kwargs)
110 self.kernel_initializer = initializers.get(kernel_initializer)
111 self.bias_initializer = initializers.get(bias_initializer)
--> 112 self.kernel_regularizer = regularizers.get(kernel_regularizer)
113 self.bias_regularizer = regularizers.get(bias_regularizer)
114 self.activity_regularizer = regularizers.get(activity_regularizer)
/Users/angermue/python/keras/keras/regularizers.py in get(identifier)
73 return None
74 if isinstance(identifier, dict):
---> 75 return deserialize(identifier)
76 elif isinstance(identifier, six.string_types):
77 config = {'class_name': str(identifier), 'config': {}}
/Users/angermue/python/keras/keras/regularizers.py in deserialize(config, custom_objects)
66 module_objects=globals(),
67 custom_objects=custom_objects,
---> 68 printable_module_name='regularizer')
69
70
/Users/angermue/python/keras/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
120 config = identifier
121 if 'class_name' not in config or 'config' not in config:
--> 122 raise ValueError('Improper config format: ' + str(config))
123 class_name = config['class_name']
124 if custom_objects and class_name in custom_objects:
ValueError: Improper config format: {'l1': 0.0, 'name': 'WeightRegularizer', 'l2': 9.999999747378752e-05} |
I have the same issues, anyone done it? |
I have solved it, firstly uninstall the version of keras 2, then install the old versio by: pip3 install keras==1.2.2 |
This is not really a solution. Keras 2 should be backward compatible and enable loading models built with Keras 1. Otherwise one would have to retrain models, which costs time and resources. |
do you have a good solution? |
Same error here.
|
I get the error when running the followin lines in Keras 2.0.4:
|
@travischoma it may cause the issue that you code used the previous version of keras. Please check it. |
@tianke0711 in my case, everything was done with 2.0.4 (my first time using the framework), so I don't believe it's a problem with regards to a model/config from an older version. |
Fixed it. Thanks |
Hi @travischoma , I am glad that you have fixed it, could you share your solution with others, please! |
@travischoma, could you please share your solution? Running into the same issue... |
Also running into this issue! Have to load model parameters from JSON. Hate it when backwards compatibility is broken. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed. |
Hi @travischoma , I'm facing the same issue. Can you tell us the fix? |
@travischoma care to share? |
I solve it,by using the version 1.2.2,just like what @tianke0711 did..... |
For those, like me, who don't have the options of reverting to 1.2.2, here is the workaround that I used, which only works if you have the model architecture saved in json format. What I found (by generating some json using 2.2.4) is that the syntax for L1/L2 regularizer has changed. So I just replaced all the instances in this format: |
This works for me. Thank you! |
Hi, I have a network generated with 1.2.2 and I could load it successfully with
However, when I upgrade to 2.0.2 and perform the same code. I got the issue:
Do you know what might be happening and what should i do? Thank you. I generate my model in this way if you think it could help...
The text was updated successfully, but these errors were encountered: