Error while reading resource variable dense_5/bias from Container: localhost
転載先:https://blog.csdn.net/qq_39564555/article/details/95475871エラーの内容は以下の通りです.
tensorflow.python.framework.errors_impl.FailedPreconditionError: Error while reading resource variable dense_1/bias from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/dense_1/bias/class tensorflow::Var does not exist
これはflaskとtensorflowが結合して現れた間違いで、いくつかの解決方法を探しました.次の最も信頼できる解決方法は次のとおりです.
tensorflow.python.framework.errors_impl.FailedPreconditionError: Error while reading resource variable dense_1/bias from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/dense_1/bias/class tensorflow::Var does not exist
これはflaskとtensorflowが結合して現れた間違いで、いくつかの解決方法を探しました.次の最も信頼できる解決方法は次のとおりです.
from tensorflow.python.keras.backend import set_session
#
sess = tf.Session()
graph = tf.get_default_graph()
# model set_session
set_session(sess)
model = models.load_model(…………)
# TensorFlow
# in each request (i.e. in each thread):
global sess
global graph
with graph.as_default():
set_session(sess)
model.predict(...)