keras在flask跑出現的問題
alueError: Tensor Tensor("dense_3/Sigmoid:0", shape=(?, 59), dtype=float32) is not an element of this graph.
原始代碼
X = img.reshape([1, 32, width, 1])
y_pred = basemodel.predict(X)
y_pred = y_pred[:, :, :]
解決方法:
在上面代碼所在的py文件前面插入
import tensorflow as tf
global graph,model
graph = tf.get_default_graph()
然在把剛剛的代碼改爲
X = img.reshape([1, 32, width, 1])
with graph.as_default():
y_pred = basemodel.predict(X)
y_pred = y_pred[:, :, :]
參考博客:https://www.cnblogs.com/svenwu/p/10189557.html
https://blog.csdn.net/lhs960124/article/details/79028691
https://blog.csdn.net/u013465194/article/details/89881317
---------------------
作者:北部灣的落日
來源:CSDN
原文:https://blog.csdn.net/qq_36213248/article/details/90049915
版權聲明:本文爲博主原創文章,轉載請附上博文鏈接!