from nets.centernet_training import focal_loss, reg_l1_loss
from keras.models import load_model
model = load_model('my_model.h5', compile=False, custom_objects={'focal_loss': focal_loss,
'reg_l1_loss': reg_l1_loss})
报错信息如下:
Traceback (most recent call last):
File "load_model_error.py", line 21, in
model = load_model('my_model.h5', compile=False, custom_objects={'focal_loss': focal_loss, 'reg_l1_loss': reg_l1_loss})
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/models.py", line 243, in load_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/models.py", line 317, in model_from_config
return layer_module.deserialize(config, custom_objects=custom_objects)
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/layers/init.py", line 55, in deserialize
printable_module_name='layer')
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 144, in deserialize_keras_object
list(custom_objects.items())))
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/engine/topology.py", line 2524, in from_config
process_node(layer, node_data)
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/engine/topology.py", line 2481, in process_node
layer(input_tensors[0], kwargs)
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/engine/topology.py", line 619, in call
output = self.call(inputs, kwargs)
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/layers/core.py", line 663, in call
return self.function(inputs, **arguments)
File "C:\Users\wisdom\Anaconda3\envs\keras-centernet\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1530, in reduce_mean_v1
NameError: name 'deprecation' is not defined
1.将模型存储
model.save('my_model.h5')
2.加载模型报错
from nets.centernet_training import focal_loss, reg_l1_loss from keras.models import load_model model = load_model('my_model.h5', compile=False, custom_objects={'focal_loss': focal_loss, 'reg_l1_loss': reg_l1_loss}) 报错信息如下: Traceback (most recent call last): File "load_model_error.py", line 21, in
model = load_model('my_model.h5', compile=False, custom_objects={'focal_loss': focal_loss, 'reg_l1_loss': reg_l1_loss})
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/models.py", line 243, in load_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/models.py", line 317, in model_from_config
return layer_module.deserialize(config, custom_objects=custom_objects)
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/layers/init.py", line 55, in deserialize
printable_module_name='layer')
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 144, in deserialize_keras_object
list(custom_objects.items())))
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/engine/topology.py", line 2524, in from_config
process_node(layer, node_data)
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/engine/topology.py", line 2481, in process_node
layer(input_tensors[0], kwargs)
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/engine/topology.py", line 619, in call
output = self.call(inputs, kwargs)
File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/layers/core.py", line 663, in call
return self.function(inputs, **arguments)
File "C:\Users\wisdom\Anaconda3\envs\keras-centernet\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1530, in reduce_mean_v1
NameError: name 'deprecation' is not defined