Tensorflow 我如何实施“Kubeflow”;“运行参数”;使用专门用于GCP的TFX SDK?

Tensorflow 我如何实施“Kubeflow”;“运行参数”;使用专门用于GCP的TFX SDK?,tensorflow,machine-learning,google-cloud-platform,kubeflow-pipelines,Tensorflow,Machine Learning,Google Cloud Platform,Kubeflow Pipelines,我目前正在使用Kubeflow作为我的编排器。orchestrator实际上是承载在GCP上的AI平台管道的实例。如何使用Tensorflow扩展SDK创建运行时参数?我怀疑这是我应该使用的类,但是文档不是很有意义,也没有提供任何示例 有点像下面的图片。 例如,您希望添加模块文件位置作为运行时参数,该参数将传递给TFX管道中的转换组件 首先设置setup_pipeline.py并定义模块文件参数: # setup_pipeline.py from typing import Text from

我目前正在使用Kubeflow作为我的编排器。orchestrator实际上是承载在GCP上的AI平台管道的实例。如何使用Tensorflow扩展SDK创建运行时参数?我怀疑这是我应该使用的类,但是文档不是很有意义,也没有提供任何示例

有点像下面的图片。

例如,您希望添加模块文件位置作为运行时参数,该参数将传递给TFX管道中的转换组件

首先设置setup_pipeline.py并定义模块文件参数:

# setup_pipeline.py

from typing import Text
from tfx.orchestration import data_types, pipeline
from tfx.orchestration.kubeflow import kubeflow_dag_runner
from tfx.components import Transform

_module_file_param = data_types.RuntimeParameter(
    name='module-file',
    default=
    '/tfx-src/tfx/examples/iris/iris_utils_native_keras.py',
    ptype=Text,
)
接下来,定义一个函数,指定管道中使用的组件并传递参数

def create_pipeline(..., module_file):
    # setup components:
    ...

    transform = Transform(
         ...
         module_file=module_file
      )
     ...

    components = [..., transform, ...]

    return pipeline.Pipeline(
          ...,
          components=components
    )
最后,设置Kubeflow DAG runner,使其将参数传递给
create_pipeline
函数。有关更完整的示例,请参见

if __name__ == "__main__":

    # instantiate a kfp_runner
    ...

    kfp_runner = kubeflow_dag_runner.KubeflowDagRunner(
        ...
    )

    kfp_runner.run(
        create_pipeline(..., module_file=_module_file_param
      ))
然后,您可以运行
python-msetup_pipeline
,它将生成指定管道配置的yaml文件,然后您可以将该文件上载到Kubeflow GCP接口