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)
    就解决啦!

发布了25 篇原创文章 · 获赞 17 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/muguangzhichen/article/details/91834667
今日推荐