shap 'KerasTensor' object has no attribute 'graph' SHAP CNN解释 报错处理

跑shap官方demo,shap.DeepExplainer报错:
shap 'KerasTensor' object has no attribute 'graph'
当时的环境是
keras == 2.4.3
tensorflow == 2.5.0
shap == 0.37
除了这个报错,还有个warning
keras is no longer supported, please use tf.keras instead.

我进行了以下尝试:
1.不使用keras,而使用tensorflow中的keras
2.
import tensorflow.compat.v1.keras.backend as K
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
3.
import tensorflow as tf
tf.compat.v1.disable_v2_behavior()

2、3都会引入新的报错信息无法解释,后来我尝试升级shap版本到最新,因为我觉得我的keras和tensorflow太新了

4.pip install shap -U
最后有个报错,看起来都没开始安装,但是shap==0.39安装好了,使用起来未见异常

Installing collected packages: slicer, shap
  Attempting uninstall: slicer
    Found existing installation: slicer 0.0.3
    Uninstalling slicer-0.0.3:
      Successfully uninstalled slicer-0.0.3
  Attempting uninstall: shap
    Found existing installation: shap 0.37.0
    Uninstalling shap-0.37.0:
      Successfully uninstalled shap-0.37.0

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: 'C:\\Users\\YH\\anaconda3\\Lib\\site-packages\\~hap\\_cext.cp38-win_amd64.pyd'
Consider using the `--user` option or check the permissions.
但是仍然有keras is no longer supported, please use tf.keras instead.的warning,但是看运行结果,感觉已经正常work




留言

熱門文章