Putu Widyantara Artanta Wibawa
03/13/2024, 4:37 AMmodel.predict(input_dict) . Below is the inference data, it's a dictionary that contain the feature name and the tensor:
input_dict = {
"feature_1": <tf.Tensor: shape=(1,), dtype=int32, numpy=array([1], dtype=int32)>,
"feature_2": <tf.Tensor: shape=(1,), dtype=float32, numpy=array([18.181818], dtype=float32)>,
...
"feature_33": <tf.Tensor: shape=(1,), dtype=int32, numpy=array([15], dtype=int32)>
}
Then I save the model, create runner, and run:
bentoml.keras.save_model(
name="embedding_dnn",
model=model,
signatures={"predict": {"batchable": True, "batch_dim": 0}},
)
runner = bentoml.keras.get("embedding_dnn:latest").to_runner()
runner.init_local()
runner.run(input_dict)
But unfortunately, I got error ValueError: Attempt to convert a value ({'feature_1': <tf.Tensor: shape=(1,), dtype=int32, numpy=array([1], ..., 'feature_33': <tf.Tensor: shape=(1,), dtype=int32, numpy=array([15], dtype=int32)>}) with an unsupported type (<class 'dict'>) to a Tensor.
Can someone help me? Is there any part that I am missing when saving the model or elsewhere?