无法将feed_dict键解释为Django中使用的Tensorflow模型中的Tensor

时间:2018-10-26 15:53:22

标签: python django tensorflow machine-learning keras

我有一个网站,可以根据几个参数预测降雨和洪水。该应用程序是用Django编写的,而预训练的模型只是添加到后端,以根据输入提供输出。

model = load_model('Model.h5')
    optimizer = tf.train.RMSPropOptimizer(0.002)
    model.compile(loss='mse',
                optimizer=optimizer,
                metrics=['accuracy'])

    pridection = np.array([minitemp,maxitemp,windgust,wind9,wind3,humid9,humid3,pressure9,pressure3,temp9,temp3])

    mean = np.array([12.068963,23.009951,37.19739,13.88135,18.25159,67.70561,49.9628,911.645197,909.72206092,16.76982,21.128429])
    std = np.array([6.47953722,7.41225215,16.68598056,9.01179628,9.14530111,20.95509877,22.34781323,310.98021687,309.95752359,6.71328472,7.64915217])
    pridection = (pridection - mean) / std

    if (pridection.ndim == 1):
        pridection = np.array([pridection])

    rainfall = model.predict(pridection)

    floods = (rainfall - 5) * 5

我得到的错误是 Cannot interpret feed_dict key as Tensor: Tensor Tensor("Placeholder:0", shape=(11, 32), dtype=float32) is not an element of this graph.

我可以在 model.compile() 语句中查明该错误正在发生,但无法确定到底是什么错误。 有人可以帮我吗?

0 个答案:

没有答案