keras+flask raise ValueError("Tensor %s is not an element of this graph." % obj)

轉載:https://blog.csdn.net/qq_36213248/article/details/90049915  

keras+flask raise ValueError("Tensor %s is not an element of this graph." % obj)

解決方法:

在上面代碼所在的py文件前面插入

    import tensorflow as tf
    global graph
    graph = tf.get_default_graph()

然在在預測代碼的前面加上:
        with graph.as_default():
            y_pred = basemodel.predict(X)
    就解決啦!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章