Hello,
I have encountered following problem after training my model, using model.save() and model.load():
Using TensorFlow backend.
Traceback (most recent call last):
File "[path1]/generate_answer.py", line 6, in
_cardio_predictor = load_model('models/3rd_run_epoch_39.h5', )_
File "[packages_path]kerasmodels.py", line 240, in load_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "[packages_path]kerasmodels.py", line 301, in model_from_config
return layer_module.deserialize(config, custom_objects=custom_objects)
File "[packages_path]keraslayers__init__.py", line 46, in deserialize
printable_module_name='layer')
File "[packages_path]kerasutilsgeneric_utils.py", line 140, in deserialize_keras_object
list(custom_objects.items())))
File "[packages_path]kerasmodels.py", line 1199, in from_config
layer = layer_module.deserialize(conf, custom_objects=custom_objects)
File "[packages_path]keraslayers__init__.py", line 46, in deserialize
printable_module_name='layer')
File "[packages_path]kerasutilsgeneric_utils.py", line 141, in deserialize_keras_object
return cls.from_config(config['config'])
File "[packages_path]kerasenginetopology.py", line 1210, in from_config
return cls(config)
**File "[packages_path]keraslayersadvanced_activations.py", line 38, in __init__
self.alpha = K.cast_to_floatx(alpha)
File "[packages_path]kerasbackendcommon.py", line 108, in cast_to_floatx
return np.asarray(x, dtype=_FLOATX)
File "[packages_path]numpycorenumeric.py", line 531, in asarray
return array(a, dtype, copy=False, order=order)
TypeError: float() argument must be a string or a number, not 'dict'
the model is as follows:
https://gist.github.com/ikamensh/b2b2ff205e482b801dd0d284c86a2dd1
saved model file is in attachment.
This issue affected me too. I fixed it by modifying the advanced_activations.py file in keras/layers as follows:
I changed this:
self.alpha = K.cast_to_floatx(alpha)
to:
try:
self.alpha = K.cast_to_floatx(alpha)
except TypeError:
self.alpha = K.cast_to_floatx(alpha['value'])
It's pretty hacky, but it fixed the issue.
I'm affected by this as well, updates?
same here, any updates?
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.
Bumped to the same problem as well, but since I used ReLU and not LeakyReLU, I changed the line (in the same file referred by @ikamensh)
self.max_value = K.cast_to_floatx(max_value)
to
try:
self.max_value = K.cast_to_floatx(max_value)
except TypeError:
self.max_value = K.cast_to_floatx(max_value['value'])
Most helpful comment
This issue affected me too. I fixed it by modifying the advanced_activations.py file in keras/layers as follows:
I changed this:
self.alpha = K.cast_to_floatx(alpha)
to:
It's pretty hacky, but it fixed the issue.