mac13k
mac13k

Reputation: 2663

How to format data for Keras multi-input model served on Google AI Platform?

Is it possible to serve multi-input Keras models on Google AI Platform? If yes - how to format the data samples for online predictions? Their documentation only covers single-input models taking JSON input like this:

{"instances": [
  {"values": [1, 2, 3, 4], "key": 1},
  {"values": [5, 6, 7, 8], "key": 2}
]}

How should it be for an AI model which takes 3 arrays on the input? I am guessing it could be something like this:

{"instances": [
  {"values": [[1, 2], [3], [4]], "key": 1}
  {"values": [[5, 6], [7], [8]], "key": 2}
]}

Am I right or am I wrong? Somebody please advise.

Upvotes: 1

Views: 85

Answers (1)

George Liu
George Liu

Reputation: 3583

Yes, you can serve multi-input models on GCP AI Platform using the Prediction service and the input JSON instances can be formatted like this:

{
   "instances":[
      {
         "input_1":[
            "..."
         ],
         "input_2":[
            "..."
         ],
         "input_3":[
            "..."
         ]
      },
      {
         "input_1":[
            "..."
         ],
         "input_2":[
            "..."
         ],
         "input_3":[
            "..."
         ]
      }
   ]
}

Upvotes: 1

Related Questions