tensorflow config_error ai_generated true

InvalidArgumentError: SavedModel 的标签集为空或与请求的标签不匹配

InvalidArgumentError: The SavedModel's tag set is empty or does not match the requested tags

ID: tensorflow/savedmodel-tagset-mismatch

其他格式: JSON · Markdown 中文 · English
92%修复率
88%置信度
1证据数
2023-01-20首次发现

版本兼容性

版本状态引入弃用备注
tensorflow 2.8 active
tensorflow 2.9 active
tensorflow 2.10 active

根因分析

使用 tf.saved_model.load() 加载 SavedModel 时,‘tags’ 参数与 SavedModel 中存在的任何 MetaGraphDef 不匹配,或者 SavedModel 保存时未指定标签。

English

When loading a SavedModel with tf.saved_model.load(), the 'tags' argument does not match any MetaGraphDef present in the SavedModel, or the SavedModel was saved without tags.

generic

官方文档

https://www.tensorflow.org/guide/saved_model#specifying_tags_when_loading

解决方案

  1. 使用 saved_model_cli show --dir /path/to/saved_model --all 列出可用的标签集,然后将正确的标签传递给 tf.saved_model.load()。例如:model = tf.saved_model.load('/path/to/saved_model', tags=['serve'])
  2. 如果未保存任何标签,请使用 tf.saved_model.load(path, tags=[]) 重新加载,或者使用显式标签重新保存模型:tf.saved_model.save(model, path, signatures=..., tags=['serve'])。

无效尝试

常见但无效的做法:

  1. 80% 失败

    The error is tag-specific, not path-related; another SavedModel may have the same tag mismatch.

  2. 95% 失败

    Debug info is unrelated to MetaGraphDef tags; the tag set remains unchanged.