Cloud ML Engine批次预测-如何简单地将返回的预测与输入数据进行匹配? [英] Cloud ML Engine batch predictions - How to simply match returned predictions with input data?
问题描述
根据 ML引擎文档,需要一个实例密钥来将返回的预测与输入数据进行匹配.为简单起见,我想使用DNNClassifier,但显然罐头估计器似乎尚不支持实例键(仅支持自定义或tensorflow核心估计器).
According to the ML Engine documentation, an instance key is required to match the returned predictions with the input data. For simplicity purposes, I would like to use a DNNClassifier but apparently canned estimators don't seem to support instance keys yet (only custom or tensorflow core estimators).
因此,我查看了Custom/TensorflowCore估算器的人口普查代码示例,但对于我要实现的目标而言,它们看起来非常复杂.
So I looked at the Census code examples of Custom/TensorflowCore Estimators but they look quite complex for what I am trying to achieve.
我宁愿使用此 stackoverflow答案中所述的类似方法(将DNNClassifier包装到自定义估算器中),但我可以 无法正常工作,并且我收到一条错误消息,说"DNNClassifier"对象没有属性"model_fn" ...
I would prefer using a similar approach as described in this stackoverflow answer (wrapping a DNNClassifier into a custom estimator) but I can not make it work and I got an error saying that 'DNNClassifier' object has no attribute 'model_fn'...
如何以一种简单的方式实现这一目标?
How can I achieve this in a simple manner?
推荐答案
按照Eli的示例我的代码:
My code as per Eli's example:
def key_model_fn_gen(estimator):
def _model_fn(feature_columns, labels, mode):
key = feature_columns.pop(KEY)
params = estimator.params
model_fn_ops = estimator._model_fn(features=feature_columns,
labels=labels,
mode=mode,
params=params)
model_fn_ops.predictions[KEY] = key
return model_fn_ops
return _model_fn
,但是使用ML Engine批量预测在预测结果中仍然无法显示实例关键字... 我需要在实验中(或可能在导出策略中)进行哪些更改 使它起作用?
but still unsuccessful to display the instance key in the result of predictions using ML Engine batch predictions... What do I need to change in the Experiment (or maybe in the export strategy) to make it work?
这篇关于Cloud ML Engine批次预测-如何简单地将返回的预测与输入数据进行匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!