Keras on Google ML Engine error: You must feed a v

2019-08-21 04:55发布

问题:

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\"]()]]\")"}

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.

Thanks

回答1:

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

As many suggestions said, I tried setting K.set_learning_phase(0) but didnt work.

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...