tensorflow AttributeError: '_UserObject' object has no attribute 'add_slot'

环境:

python3.6
tensorflow2.6.0

使用 tf.saved_model.load 加载模型错误

AttributeError: '_UserObject' object has no attribute 'add_slot'

解决方案1:

升级到 tensorflow 2.7 以上

解决方案2:

import tensorflow as tf
from tensorflow.keras import models  #加此行即可解决, 或  from tensorflow.keras import Model

解决方案3:

使用 model.save_weights()  和 model.load_weights()
posted @ 2022-04-01 15:14  鱼与鱼  阅读(1042)  评论(0编辑  收藏  举报