google-cloud-platform - 如何在 ML Engine 上调试预测,预测返回空数组
问题描述
我正在实现一个 tfx 管道,类似于芝加哥出租车示例 推送模型的预测返回{"predictions": []}
。我该如何调试这个问题?
我可以看到正在做出的预测的日志。但是因为它返回一个空数组,所以状态码是 200,并且没有关于出错的有用信息。我希望预测请求数据没有正确传递给估计器。
芝加哥示例使用它作为他们的服务接收器并且有效。我认为它也应该适用于我的示例
def _example_serving_receiver_fn(transform_output, schema):
"""Build the serving in inputs.
Args:
transform_output: directory in which the tf-transform model was written
during the preprocessing step.
schema: the schema of the input data.
Returns:
Tensorflow graph which parses examples, applying tf-transform to them.
"""
raw_feature_spec = _get_raw_feature_spec(schema)
raw_feature_spec.pop(_LABEL_KEY)
raw_input_fn = tf.estimator.export.build_parsing_serving_input_receiver_fn(
raw_feature_spec, default_batch_size=None)
serving_input_receiver = raw_input_fn()
transformed_features = transform_output.transform_raw_features(
serving_input_receiver.features)
return tf.estimator.export.ServingInputReceiver(
transformed_features, serving_input_receiver.receiver_tensors)
主要区别在于我只期望 1 个输入:一串由 . 分隔的编程语言'|': 'java|python'
。
然后,我在我的预处理函数中将该字符串拆分并使其成为形状为 500 的多一热编码数组(我正好有 500 个选项)
也可能是预测没有被 tf transform 正确转换的情况。(tf 转换是 tfx 管道的一部分并且运行正确)
要求:{"instances": ["javascript|python"]}
回复:{"predictions": []}
预期响应:({"predictions": [520]}
它是一个回归模型)
解决方案
推荐阅读
- acumatica - 添加新项目时未插入子 DAC
- jenkins - 具有声明性 Jenkins 管道的主动选择参数
- python - 使用 Python 从打印按钮下载文件
- single-sign-on - OpenAM 跨域 cookie 'Iplanetdirectorypro' 作为 IIS 的响应而过期
- oauth - 我们真的需要 client_secret 来获取 PKCE 流上的 access_token 吗?
- ruby-on-rails - 仅远程环境中的 Capybara 错误
- javascript - 格式化显示在多个 Radialbars ApexChart 上的数据
- python - python pandas基于另一列对列值进行条件编辑
- java - Okhttp3 需要为一个对象设置 unquie 属性值,例如 readtimeout
- c - 输出未在 C 中显示