python - 在带有 DataFlow 的 preprocessing_fn 中使用 tf.py_function 会导致 ValueError: callback pyfunc_16 is not found (Github 中的代码)
问题描述
我正在尝试在 Kubeflow Pipelines 上为 TFX运行这个Keras 组件DataflowRunner
笔记本,但使用and 并稍作改动。在preprocessing_fn
我替换tft.scale_to_z_score(_fill_in_missing(inputs[key]))
为以下内容:
from sklearn.preprocessing import scale
def sk_scale_to_z_score(X):
scaled = scale(X)
return scaled
@tf.function
def tf_scale_to_z_score(X):
X_shape = X.shape
[X_scaled, ] = tf.py_function(sk_scale_to_z_score, [X], [tf.float32])
X_scaled.set_shape(X_shape)
return X_scaled
所以最终的代码片段如下所示:
outputs[_transformed_name(key)] = tf_scale_to_z_score(_fill_in_missing(inputs[key]))
但是,此管道在引发以下错误的Transform
步骤中停止:Dataflow
ValueError: callback pyfunc_16 is not found
因此,我的问题是:如果我正在使用,tf.py_function
那么我可以使用Dataflow
吗?如果是,那么如何?
编辑:代码可以在这个github repo中找到。
解决方案
推荐阅读
- kubernetes - 如何将节点选择器添加到 Kubernetes 中的系统 pod?
- c++ - 向量导致的错误
? - git - 我如何 Eslint 只更改代码行
- html - CSS - 同时显示线性和径向背景
- android - 禁用不可见视图组的单击侦听器
- reactjs - 为什么 React 中我的图像下方有大量空白区域?是什么创造了这个神秘的 div?
- r-markdown - 在 bookdown 标题前添加图片
- python - 如何遍历 TextBlob WordList 并找到最常用的名词?
- python - Python 应用程序帮助
- javascript - 如何忽略 ChartJs 上的相同值?