未指定版本且未找到模型的默认版本

No version was specified and no default version for the model was found

我将我的预测模型上传到 Google 的机器学习引擎。当我运行

gcloud ml-engine predict --model=earnings --json-instances=sample_input_prescaled.json

我收到错误

ERROR: (gcloud.ml-engine.predict) HTTP request failed. Response: {
  "error": {
"code": 400,
"message": "Field: name Error: No version was specified and no default version for the model was found.",
"status": "INVALID_ARGUMENT",
"details": [
  {
    "@type": "type.googleapis.com/google.rpc.BadRequest",
    "fieldViolations": [
      {
        "field": "name",
        "description": "No version was specified and no default version for the model was found."
      }
    ]
  }
]
  }
}

如何为我的模型添加版本?

如果您使用 Web 界面调出模型,则可以向您的模型添加一个版本。即ML Engine > Models > [model name] > Create a version.

还要确保您的变量文件仍在存储桶的 variables 目录中。当我将模型复制过来 (gsutil cp -R exported_model/* gs://keras-class-191806/earnings_v1) 时,模型的目录结构被展平了。恢复变量文件夹并将变量文件移动到里面。