平台

  • ubuntu
  • tensoflow

现象

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_39/883809998.py in <module>
----> 1 model0 = tf.saved_model.load('../input/ubiquant-dataset/nn0')/opt/conda/lib/python3.7/site-packages/tensorflow/python/saved_model/load.py in load(export_dir, tags, options)862   """863   metrics.IncrementReadApi(_LOAD_V2_LABEL)
--> 864   result = load_internal(export_dir, tags, options)["root"]865   metrics.IncrementRead()866   return result/opt/conda/lib/python3.7/site-packages/tensorflow/python/saved_model/load.py in load_internal(export_dir, tags, options, loader_cls, filters)901       try:902         loader = loader_cls(object_graph_proto, saved_model_proto, export_dir,
--> 903                             ckpt_options, options, filters)904       except errors.NotFoundError as err:905         raise FileNotFoundError(/opt/conda/lib/python3.7/site-packages/tensorflow/python/saved_model/load.py in __init__(self, object_graph_proto, saved_model_proto, export_dir, ckpt_options, save_options, filters)160     self._filtered_nodes = self._retrieve_all_filtered_nodes()161
--> 162     self._load_all()163 164     if not save_options.experimental_skip_checkpoint:/opt/conda/lib/python3.7/site-packages/tensorflow/python/saved_model/load.py in _load_all(self)257   def _load_all(self):258     """Loads all nodes and functions from the SavedModel and their edges."""
--> 259     self._load_nodes()260     self._load_edges()261     # TODO(b/124045874): There are limitations with functions whose captures/opt/conda/lib/python3.7/site-packages/tensorflow/python/saved_model/load.py in _load_nodes(self)446         optimized_variable = nodes[447             slot_variable_proto.original_variable_node_id]
--> 448         slot_variable = optimizer_object.add_slot(449             var=optimized_variable,450             slot_name=slot_variable_proto.slot_name)AttributeError: '_UserObject' object has no attribute 'add_slot'

解决

  • 起初我猜测我训练用tensorflow2.3.1,加载模型用2.6.2。二者不一致导致,半天功夫升级cuda、cudnn和tf后,问题仍然存在
  • 加载pb模型时,采用了tf.keras.models.load_model,替换tf.saved_model.load。问题解决

参考

  • https://github.com/tensorflow/models/issues/8990

debug Tensorflow: ‘_UserObject‘ object has no attribute ‘add_slot‘相关推荐

  1. 成功解决tensorflow.keras: AttributeError: ‘str‘ object has no attribute ‘decode‘

    tensorflow.keras: AttributeError: 'str' object has no attribute 'decode' 出现该问题,解决分两步首先检测自身的版本是否对应, 然 ...

  2. Tensorflow报错:AttributeError: 'module' object has no attribute 'scalar_summary'

    报错: tf.scalar_summary(l.op.name + ' (raw)', l) AttributeError: 'module' object has no attribute 'sca ...

  3. M1Mac使用TensorFlow出现AttributeError: ‘h5py.h5t.TypeID‘ object has no attribute ‘set_fields‘的解决办法

    问题 TensorFlow使用Apple官方优化版2.4.1(conda-forge),使用tf.keras后端时候出现: AttributeError: 'h5py.h5t.TypeID' obje ...

  4. tensorflow出现如下错误:AttributeError: ‘module’ object has no attribute ‘merge_all_summaries’

    tensorflow版本问题,导致函数的变化,summary使用如下变化机制: AttributeError: 'module' object has no attribute 'merge_all_ ...

  5. ‘tensorflow.python.framework.ops.EagerTensor‘ object has no attribute ‘reshape‘

    'tensorflow.python.framework.ops.EagerTensor' object has no attribute 'reshape' 可以将其用numpy读取后再reshap ...

  6. ‘Tensor‘ object has no attribute ‘_keras_history‘——keras和tensorflow版本不兼容

    'Tensor' object has no attribute '_keras_history'--keras和tensorflow版本不兼容 每天踩一坑,坑坑不一样,每天的生活状态就是踩坑踩坑,爬 ...

  7. 北京大学曹建老师tensorflow慕课中在运行GRU模型时,history = model.fit()中遇到的问题:object has no attribute ‘dtype‘

    1.在运行下方代码时,遇到了 history = model.fit(x_train, y_train, batch_size=64, epochs=50, validation_data=(x_te ...

  8. tensorflow报错:AttributeError: 'module' object has no attribute 'get_or_create_global_step'

    Tensorflow 1.0训练官方教程中CIFAR10例子 官方教程 执行   python cifar10_train.py时 报错: AttributeError: 'module' objec ...

  9. 'module' object has no attribute 'scalar_summary'

    TensorFlow不同版本引起的错误 报错: tf.scalar_summary(l.op.name + ' (raw)', l) AttributeError: 'module' object h ...

最新文章

  1. dlib人脸比对算法代码java,Python 使用dlib 5行代码实现人脸比对
  2. 你说我画,你画我说:全球最大中文跨模态生成模型文心ERNIE-ViLG来了!
  3. 干货丨机器学习傻瓜指南
  4. python 重写断言_历时四年,Dropbox 用 Rust 重写同步引擎核心代码
  5. springboot设置默认值_spring boot jpa存储数据的默认值为java的默认值
  6. 如何和后台接触的_后台产品,不只是做支持
  7. 关于大型网站技术演进的思考(十四)--网站静态化处理—前后端分离—上(6)...
  8. vb6计算机,[计算机软件及应用]VB6.ppt
  9. c语言笔试题7(25),嵌入式软件工程师C语言笔试题(7页)-原创力文档
  10. ProE5.0有限元分析优化设计Mechanica视频教程
  11. css中如何使图标的旋转
  12. 手把手教你软件著作权申请(全流程)(不花一分冤枉钱)
  13. 人生就是个学习、思考与实践的过程
  14. opencv之伪彩变换
  15. Android8.0未知来源应用安装权限
  16. GIT fatal: unable to auto-detect email address (got 'Administrator@DESKTOP-880G72L.(none)')
  17. 自考计算机专业实践报不了名,2014年9月北京自考计算机及应用专业实践课程网报通知...
  18. 出现BOOTMGR is missing 最简单实用的解决方案
  19. JAVA面试100道必考题
  20. 精选| 2020年5月R新包推荐(第42期)

热门文章

  1. IOS内置safari浏览器日期字符串转Date对象失败
  2. java gc --- 关键词解释
  3. Acdream1157---Segments (CDQ分治)
  4. Mysql是否开启binlog日志开启方法
  5. html5相关笔记(一)
  6. 三点顺序(计算几何)
  7. Groovy/Spock 测试导论
  8. (十三)洞悉linux下的Netfilteramp;iptables:为防火墙增添功能模块【实战】
  9. ubuntu12.04安装KDevelop
  10. List的遍历 Java