日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

debug Tensorflow: ‘_UserObject‘ object has no attribute ‘add_slot‘

發布時間:2025/3/12 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 debug Tensorflow: ‘_UserObject‘ object has no attribute ‘add_slot‘ 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

平臺

  • 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‘的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。