Cannot interpret feed_dict key as Tensor: Tensor Tensor (...) is not an element of this graph.
程序员文章站
2022-06-17 10:53:07
...
Flask 服务,预先加载Keras的h5模型,web调用模型进行预测时出现错误
错误详情如下:
Cannot interpret feed_dict key as Tensor: Tensor Tensor(“Placeholder:0”, shape=(5, 5, 3, 64), dtype=float32) is not an element of this graph.
解决方法如下:
加载完模型完,进行调用预测的时候,进行以下操作。
import tensorflow as tf
graph = tf.get_default_graph() # 功能:获取当前默认计算图。
with graph.as_default():
'''
你的预测的逻辑代码
'''