AttributeError: module ‘keras.backend‘ has no attribute ‘get_session‘ 问题解决

简介: TensorFlow和 Keras 的版本太高导致的

一、问题


Traceback (mostrecentcalllast):
File"video.py", line9, in<module>ssd=SSD()
File"/home/pi/Desktop/Mobilenet-SSD-Essay-master/ssd.py", line37, in__init__self.sess=K.get_session()
AttributeError: module'keras.backend'hasnoattribute'get_session'


原因:TensorFlow和 Keras 的版本太高导致的,我的版本如下:TensorFlow2.3.0、Keras2.4.3


二、解决方法


先定位到这行代码

fromkerasimportbackendasK


改为

fromtensorflow.compat.v1.kerasimportbackendasK
目录
相关文章
|
TensorFlow 算法框架/工具 Python
成功解决AttributeError: module 'numpy' has no attribute 'equal'
成功解决AttributeError: module 'numpy' has no attribute 'equal'
成功解决AttributeError: module 'numpy' has no attribute 'equal'
AttributeError: module ‘torch.jit‘ has no attribute ‘_script_if_tracing‘
AttributeError: module ‘torch.jit‘ has no attribute ‘_script_if_tracing‘
295 0
AttributeError: module ‘torch.utils‘ has no attribute ‘data‘
属性错误:模块的'torch.utils'没有属性'data'
101 0
|
Linux Windows
AttributeError: module ‘websocket‘ has no attribute ‘enableTrace‘
AttributeError: module ‘websocket‘ has no attribute ‘enableTrace‘
787 0
AttributeError: module ‘websocket‘ has no attribute ‘enableTrace‘
|
TensorFlow API 算法框架/工具
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
335 0
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
|
TensorFlow API 算法框架/工具
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘
173 0
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘
TensorRT:AttributeError: 'module' object has no attribute 'Logger'
TensorRT:AttributeError: 'module' object has no attribute 'Logger'
236 0
|
PyTorch 算法框架/工具
问题解决:AttributeError: 'module' object has no attribute '_rebuild_tensor_v2'
问题解决:AttributeError: 'module' object has no attribute '_rebuild_tensor_v2'
277 0
|
计算机视觉
AttributeError: module 'cv2' has no attribute 'xfeatures2d'问题解决
AttributeError: module 'cv2' has no attribute 'xfeatures2d'问题解决
3278 0
|
TensorFlow 算法框架/工具
TF版本升级问题:成功解决AttributeError: module tensorflow has no attribute mul
TF版本升级问题:成功解决AttributeError: module tensorflow has no attribute mul
TF版本升级问题:成功解决AttributeError: module tensorflow has no attribute mul