【AttributeError: ‘XXX‘ object has no attribute ‘

【AttributeError: ‘XXX‘ object has no attribute ‘,第1张

参考链接:https://www.jianshu.com/p/9da54361d289

环境:

硬件:gpu(nvidia GeForce rtx 2060)
软件:keras=2.3.1
	  tensorflow=2.1.0
	  tensorboard=2.1.0
	  CUDA=10.0
	  cudnn=7.4
	  CUDA Driver = CUDART, CUDA Driver Version = 11.6, CUDA Runtime Version = 10.0, NumDevs = 1, Device0 = NVIDIA GeForce RTX 2060
	  numpy=1.16.5(这个版本有警告,估计还是不太匹配)

错误原因:keras和tensorflow及tensorboard之间的版本不匹配,模型用的是keras的,且keras的Backend使用的是tensorflow,而tensorflow有些版本里面自带的tensorflow_keras的一些属性和keras库的不完全统一。

三者之间版本匹配可查看:https://mckayward.github.io/floyd-docs/guides/environments/

解决方法一:改到匹配版本,有点难。

解决方法二:修改报错的callback.py文件,添加判断是否有’_is_graph_network’属性。我的在D:\XXXXXX\Install\anaconda3\envs\430gpu\Lib\site-packages\tensorflow_core\python\keras\callbacks.py

with context.eager_mode():
      self._close_writers()
      if self.write_graph:
        with self._get_writer(self._train_run_name).as_default():
          with summary_ops_v2.always_record_summaries():
            if not model.run_eagerly:
              summary_ops_v2.graph(K.get_graph(), step=0)

            # summary_writable = (
            #     self.model._is_graph_network or  # pylint: disable=protected-access
            #     self.model.__class__.__name__ == 'Sequential')  # pylint: disable=protected-access
            if hasattr(self.model, '_is_graph_network'):
              summary_writable = (
                  self.model._is_graph_network or  # pylint: disable=protected-access
                  self.model.__class__.__name__ == 'Sequential')  # pylint: disable=protected-access
            else:
              summary_writable = self.model.__class__.__name__ == 'Sequential'
            if summary_writable:
              summary_ops_v2.keras_model('keras', self.model, step=0)

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/869359.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-13
下一篇 2022-05-13

发表评论

登录后才能评论

评论列表(0条)

保存