keras 并发load_model报错

我通过web代码实时加载模型进行预测,但报如下错误
Traceback (most recent call last):
File "/root/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1997, in call
return self.wsgi_app(environ, start_response)
File "/root/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/root/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/root/anaconda3/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/root/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/root/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/root/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/root/anaconda3/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/root/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/root/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "/root/anaconda3/code/App.py", line 41, in predict
model=load_model(root_path+model_name)
File "/root/anaconda3/lib/python3.6/site-packages/keras/models.py", line 249, in load_model
topology.load_weights_from_hdf5_group(f['model_weights'], model.layers)
File "/root/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 3008, in load_weights_from_hdf5_group
K.batch_set_value(weight_value_tuples)
File "/root/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2189, in batch_set_value
get_session().run(assign_ops, feed_dict=feed_dict)
File "/root/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 895, in run
run_metadata_ptr)
File "/root/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1071, in _run

  • e.args[0]) TypeError: Cannot interpret feed_dict key as Tensor: Tensor Tensor("Placeholder:0", shape=(1, 16), dtype=float32) is not an element of this graph.

1个回答

先运行一遍predict 可能就好了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问