iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 11
0
DevOps

30 Days of MLOps系列 第 11

呼叫 Predict API - 30 Days of MLOps

  • 分享至 

  • xImage
  •  

呼叫預測(Predict) API 取得 Model 的預測結果

語法

POST http://host:port/v1/models/${MODEL_NAME}[/versions/${VERSION}|/labels/${LABEL}]:predict

API 呼叫範例

curl -d '{"instances": [1.0,2.0,5.0]}' -X POST http://localhost:8501/v1/models/saved_model_half_plus_three:predict

Request

Request 參數語法格式

{
  // (Optional) Serving signature to use.
  // If unspecifed default serving signature is used.
  "signature_name": <string>,

  // Input Tensors in row ("instances") or columnar ("inputs") format.
  // A request can have either of them but NOT both.
  "instances": <value>|<(nested)list>|<list-of-objects>
  "inputs": <value>|<(nested)list>|<object>
}

Request 範例

{
  // List of 3 scalar tensors.
  "instances": [ "foo", "bar", "baz" ]
}

{
  // List of 2 tensors each of [1, 2] shape
  "instances": [ [[1, 2]], [[3, 4]] ]
}

Response

Response 語法格式

{
  "predictions": <value>|<(nested)list>|<list-of-objects>
}
{
  "outputs": <value>|<(nested)list>|<object>
}

Response 範例

{
  "predictions": [3.5, 4.0, 5.5]
}

參考資料

- Classification: 分類
- Regression:回歸
- Predict:預測

上一篇
呼叫 Classify 和 Regress API - 30 Days of MLOps
下一篇
訓練 Model
系列文
30 Days of MLOps23
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言