Google ML Engine上的Keras错误:您必须提供占位符张量的值

时间:2018-09-03 14:02:10

标签: tensorflow machine-learning keras neural-network google-cloud-ml

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

{"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),但没有成功。

谢谢

1 个答案:

答案 0 :(得分:2)

让我猜测-您的模型具有批量归一化层,对吗? :)

  

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

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

K.set_learning_phase(0)

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

相关问题