Pusher TFX 管道元件

Pusher 元件用於在模型訓練或重新訓練期間,將經過驗證的模型推送至部署目標。在部署之前,Pusher 仰賴其他驗證元件的一個或多個核准,以判斷是否推送模型。

  • Evaluator 會在新的訓練模型「夠好」可推送至生產環境時核准模型。
  • (選用但建議) 如果模型在生產環境中在機械上可提供服務,InfraValidator 會核准模型。

Pusher 元件會取用 SavedModel 格式的已訓練模型,並產生相同的 SavedModel 以及版本控制中繼資料。

使用 Pusher 元件

Pusher 管道元件通常非常容易部署,而且幾乎不需要自訂,因為所有工作都由 Pusher TFX 元件完成。典型程式碼如下所示

pusher = Pusher(
  model=trainer.outputs['model'],
  model_blessing=evaluator.outputs['blessing'],
  infra_blessing=infra_validator.outputs['blessing'],
  push_destination=tfx.proto.PushDestination(
    filesystem=tfx.proto.PushDestination.Filesystem(
        base_directory=serving_model_dir)
  )
)

推送從 InfraValidator 產生的模型。

(從 0.30.0 版起)

InfraValidator 也可以產生 InfraBlessing 成品,其中包含具有暖機功能的模型,而 Pusher 可以像推送 Model 成品一樣推送該成品。

infra_validator = InfraValidator(
    ...,
    # make_warmup=True will produce a model with warmup requests in its
    # 'blessing' output.
    request_spec=tfx.proto.RequestSpec(..., make_warmup=True)
)

pusher = Pusher(
    # Push model from 'infra_blessing' input.
    infra_blessing=infra_validator.outputs['blessing'],
    push_destination=tfx.proto.PushDestination(...)
)

Pusher API 參考資料中提供更多詳細資訊。