Skip to Content
构建机器学习管道
book

构建机器学习管道

by Hannes Hapke, Catherine Nelson
May 2025
Intermediate to advanced
366 pages
4h 36m
Chinese
O'Reilly Media, Inc.
Content preview from 构建机器学习管道

附录 C. Kubeflow 管道操作提示

当您使用 Kubeflow Pipelines 运行 TFX 管道时,您可能希望自定义 TFX 组件的底层容器映像。如果您的组件依赖于 TensorFlow 和 TFX 包之外的其他 Python 依赖项,则需要自定义 TFX 映像。在我们的演示管道中,我们有一个额外的 Python 依赖项,即 TensorFlow Hub 库,用于访问我们的语言模型。

在本附录的后半部分,我们将向你展示如何在本地计算机和持久卷之间传输数据。如果你能通过云存储提供商访问数据(例如,使用内部 Kubernetes 集群),那么持久卷的设置将非常有益。下面介绍的步骤将指导您完成将数据复制到群集和从群集复制数据的过程。

定制 TFX 图片

在我们的示例项目中,我们使用了 TensorFlow Hub 提供的语言模型。 我们使用 库来高效加载语言模型。原始 TFX 映像中并没有这个特定库;因此,我们需要用所需库构建一个自定义 TFX 映像。如果您计划使用自定义组件(如tensorflow_hub 第 10 章中讨论的组件),情况也是如此。

幸运的是,正如我们在附录 A 中讨论的那样,Docker 镜像的构建并不麻烦。下面的Dockerfile显示了我们的自定义镜像设置:

FROM tensorflow/tfx:0.22.0

RUN python3.6 -m pip install "tensorflow-hub" 1
RUN ... 2

ENTRYPOINT ["python3.6", "/tfx-src/tfx/scripts/run_executor.py"] 3
1

安装所需软件包

2

如有需要,请安装其他软件包。

3

不要更改容器入口点。

我们可以轻松地继承标准 TFX 映像,将其作为自定义映像的基础。为避免 TFX API 发生任何突然变化,我们强烈建议将基础镜像的版本固定为特定的构建版本(如tensorflow/tfx:0.22.0),而不是常见的latest 标签。TFX 映像基于 Ubuntu Linux 发行版构建,并已安装 Python。在我们的例子中,只需为 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

What Successful Brick-and-Mortar Retailers Get Right

What Successful Brick-and-Mortar Retailers Get Right

Rob Angell
Search Marketing

Search Marketing

Kelly Cutler
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer

Publisher Resources

ISBN: 9798341659292