我请求对经过训练的模型(使用线性学习算法创建的模型)进行在线预测,并收到“错误”:“预测失败:未知错误。”
这是我在 Google AI 平台中的第一个机器学习模型。模型训练成功,训练数据、验证数据和测试数据在输出文件夹中看起来都很好。但是当我尝试通过传递输入 JSON 来测试模型时,出现此错误。我寻找过类似的其他帖子,但找不到成功预测的解决方案。
工件文件夹中的metadata.json 看起来像
{
"feature_columns": {
"col_0": {
"mapping": {
"0": 0,
"1": 1,
"10": 10,
"2": 2,
"3": 3,
"4": 4,
"5": 5,
"6": 6,
"7": 7,
"8": 8,
"9": 9
},
"mode": "0",
"num_category": 11,
"treatment": "identity",
"type": "categorical"
},
"col_1": {
"mapping": {
"0": 0,
"1": 1,
"10": 10,
"2": 2,
"3": 3,
"4": 4,
"5": 5,
"6": 6,
"7": 7,
"8": 8,
"9": 9
},
"mode": "4",
"num_category": 11,
"treatment": "identity",
"type": "categorical"
}
},
"target_algorithm": "TensorFlow",
"target_column": {
"type": "regression"
}
}
我传递用于测试预测的输入 JSON 是 {“实例”:[5,5]}
模型预计将对 2 个输入特征求和并给出结果 10
请您指出错误在哪里?
最佳答案
如果您使用 gcloud 发送文件,请执行以下操作:
{"col_0": "5", "col_1": "5" }
如果您通过其他客户端发送一堆实例,请执行以下操作:
{
"instances": [
{"col_0": "5", "col_1": "5" },
{"col_0": "3", "col_1": "2" }
]
}
关于google-cloud-ml - "error": "Prediction failed: unknown error.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57874778/