{
  "id": "tensorflow/savedmodel-signature-def-not-found",
  "signature": "ValueError: Could not find signature def corresponding to requested signature key 'serving_default'",
  "signature_zh": "值错误：找不到与请求的签名键 'serving_default' 对应的签名定义",
  "regex": "Could not find signature def corresponding to requested signature key 'serving_default'",
  "domain": "tensorflow",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "SavedModel was exported without a default serving signature or with a different signature name, causing model loading to fail when expecting 'serving_default'.",
  "root_cause_type": "generic",
  "root_cause_zh": "SavedModel 导出时没有默认服务签名或使用了不同的签名名称，导致加载模型时因期望 'serving_default' 而失败。",
  "versions": [
    {
      "version": "tensorflow 2.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tensorflow 2.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tensorflow 2.13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tensorflow 2.14",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Re-exporting the model with tf.saved_model.save without specifying signatures",
      "why_fails": "If the model's call method is not defined, default signature may still be missing; need to explicitly provide signatures.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Renaming the signature key in the loader to match a non-existent key",
      "why_fails": "The key must match an actual signature in the SavedModel; guessing keys rarely works.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "List available signatures in the SavedModel: import tensorflow as tf; loaded = tf.saved_model.load('model_dir'); print(list(loaded.signatures.keys())). Then use the correct key: model = tf.saved_model.load('model_dir', tags='serve', signature='your_correct_key')",
      "success_rate": 0.9,
      "how": "List available signatures in the SavedModel: import tensorflow as tf; loaded = tf.saved_model.load('model_dir'); print(list(loaded.signatures.keys())). Then use the correct key: model = tf.saved_model.load('model_dir', tags='serve', signature='your_correct_key')",
      "condition": "",
      "sources": []
    },
    {
      "action": "Re-export the model with an explicit serving signature: @tf.function(input_signature=[tf.TensorSpec(shape=[None, 224, 224, 3], dtype=tf.float32)]); def serving_fn(input): return self.call(input); tf.saved_model.save(model, 'model_dir', signatures={'serving_default': serving_fn})",
      "success_rate": 0.85,
      "how": "Re-export the model with an explicit serving signature: @tf.function(input_signature=[tf.TensorSpec(shape=[None, 224, 224, 3], dtype=tf.float32)]); def serving_fn(input): return self.call(input); tf.saved_model.save(model, 'model_dir', signatures={'serving_default': serving_fn})",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "List available signatures in the SavedModel: import tensorflow as tf; loaded = tf.saved_model.load('model_dir'); print(list(loaded.signatures.keys())). Then use the correct key: model = tf.saved_model.load('model_dir', tags='serve', signature='your_correct_key')",
    "Re-export the model with an explicit serving signature: @tf.function(input_signature=[tf.TensorSpec(shape=[None, 224, 224, 3], dtype=tf.float32)]); def serving_fn(input): return self.call(input); tf.saved_model.save(model, 'model_dir', signatures={'serving_default': serving_fn})"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.tensorflow.org/guide/saved_model#specifying_signatures_during_export",
  "official_doc_section": null,
  "error_code": "SSD",
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2023-07-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}