Google ML Engine上的Keras错误:您必须提供占位符张量的值 [英] Keras on Google ML Engine error: You must feed a value for placeholder tensor

查看:137
本文介绍了Google ML Engine上的Keras错误:您必须提供占位符张量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Google Cloud ML Engine上部署了一个模型,但是当我尝试执行预测(我正在使用curl)时,这是我获得的结果:

I have deployed a model on Google Cloud ML Engine, but when I try to perform a prediction (I'm using curl), this is the result I obtain:

{"error": "Prediction failed: Error during model execution: AbortionError(code=StatusCode.INVALID_ARGUMENT, details=\"You must feed a value for placeholder tensor 'lstm_1/keras_learning_phase' with dtype bool\n\t [[Node: lstm_1/keras_learning_phase = Placeholder[dtype=DT_BOOL, shape=[], _device=\"/job:localhost/replica:0/task:0/device:CPU:0\"]()]]\")"}

如何精确设置此占位符张量的值?它在json上吗?训练期间必须做些什么吗?正如许多建议所说,我尝试设置K.set_learning_phase(0)但没有用.

How exactly can I set the value of this placeholder tensor? Is it on the json? Is it something that has to be done during training? As many suggestions said, I tried setting K.set_learning_phase(0) but didnt work.

谢谢

推荐答案

让我猜测-您的模型具有批处理规范化层,对吗? :)

Let me guess - your model has batch normalization layers, right? :)

正如许多建议所说,我尝试设置K.set_learning_phase(0)但没有用.

确实-几天前我碰巧遇到了同样的问题;解决方案是设置

Indeed - I happened to have the same problem a couple of days ago; the solution is to set

K.set_learning_phase(0)

之前初始化(或加载)模型-如果稍后在脚本中执行此操作,则该错误会不断弹出...

before initializing (or loading) your model - if you do it later in the script, the said error keeps poping up...

这篇关于Google ML Engine上的Keras错误:您必须提供占位符张量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆