keras AttributeError: 'Node' object has no attribute 'output_masks'

使用keras,出错

Traceback (most recent call last):
 File "./real-time.py", line 8, in <module>
   detect_hand = Detector(weights='weights/solo.h5', threshold=0.8)
 File "/home/zm/下载/Unified-Gesture-and-Fingertip-Detection/SOLO/solo.py", line 11, in __init__
   self.model = model()
 File "/home/zm/下载/Unified-Gesture-and-Fingertip-Detection/SOLO/model.py", line 9, in model
   x = Conv2D(1, (1, 1), activation='sigmoid')(x)
 File "/home/zm/tensor/lib/python3.6/site-packages/keras/engine/base_layer.py", line 446, in __call__
   previous_mask = _collect_previous_mask(inputs)
 File "/home/zm/tensor/lib/python3.6/site-packages/keras/engine/base_layer.py", line 1326, in _collect_previous_mask
   mask = node.output_masks[tensor_index]
AttributeError: 'Node' object has no attribute 'output_masks'

解决

查看tensorflow 及keras版本

import tensorflow as tf

>>> print(tf.__version__)
1.14.0
>>> import keras
Using TensorFlow backend.
>>> print(keras.__version__)
2.2.0
再到官网查看tensorflow及keras兼容版本关系

https://docs.floydhub.com/guides/environments/

发现tensorflow1.14.0对应的是keras2.2.5 ,于是手动升级keras到2.2.5

pip install --upgrade keras==2.2.5

作者:帅得不敢出门

发布了201 篇原创文章 · 获赞 20 · 访问量 41万+

猜你喜欢

转载自blog.csdn.net/zmlovelx/article/details/103306480