I made a Keras model
model = Sequential()
model.add(Dense(12, input_dim=7, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
Trained it locally
# Compile model
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# Fit the model
model.fit(X_train, Y_train, epochs=150, batch_size=10)
Tested that it works
example = np.array([X_test.iloc[0]])
model.predict(example)
saved it using this function
def to_savedmodel(model, export_path):
"""Convert the Keras HDF5 model into TensorFlow SavedModel."""
builder = saved_model_builder.SavedModelBuilder(export_path)
signature = predict_signature_def(inputs={'input': model.inputs[0]},
outputs={'income': model.outputs[0]})
K.clear_session()
sess = K.get_session()
builder.add_meta_graph_and_variables(
sess=sess,
tags=[tag_constants.SERVING],
signature_def_map={
signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY: signature}
)
sess.close()
K.clear_session()
builder.save()
The model is now in GC Storage in .pb
format.
I made a new model in ML Engine and deploy this first version.
When I try to use it via HTTP POST
request using this json body
{
"instances": [{
"input": [1, 2, 3, 4, 5, 6, 7 ]
}]
}
I get this Error:
{
"error": "Prediction failed: Error during model execution: AbortionError(code=StatusCode.NOT_FOUND, details=\"FeedInputs: unable to find feed output dense_34_input:0\")"
}
Any idea how can I send the correct Body or save the model correctly?