# 值错误：找不到与请求的签名键 'serving_default' 对应的签名定义

- **ID:** `tensorflow/savedmodel-signature-def-not-found`
- **领域:** tensorflow
- **类别:** config_error
- **错误码:** `SSD`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

SavedModel 导出时没有默认服务签名或使用了不同的签名名称，导致加载模型时因期望 'serving_default' 而失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| tensorflow 2.11 | active | — | — |
| tensorflow 2.12 | active | — | — |
| tensorflow 2.13 | active | — | — |
| tensorflow 2.14 | active | — | — |

## 解决方案

1. ```
   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')
   ```
2. ```
   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})
   ```

## 无效尝试

- **Re-exporting the model with tf.saved_model.save without specifying signatures** — If the model's call method is not defined, default signature may still be missing; need to explicitly provide signatures. (60% 失败率)
- **Renaming the signature key in the loader to match a non-existent key** — The key must match an actual signature in the SavedModel; guessing keys rarely works. (90% 失败率)
