Shap包的tf_ops._gradient_registry._registry中不存在ClipByValue

时间:2018-07-26 04:09:33

标签: python machine-learning deep-learning

我尝试通过以下示例在python中使用shap包来解释深度学习模型。 https://slundberg.github.io/shap/notebooks/Front%20Page%20DeepExplainer%20MNIST%20Example.html

当我调用explorer.shap_values(test [:2])时,遇到了KeyError-ClipByValue。

显然我的tf_ops._gradient_registry._registry中没有ClipByValue。

有帮助吗?

1 个答案:

答案 0 :(得分:2)

我今天也遇到了这个问题。

在调查中,我将这个问题隔离在Shap中。 v0.19.3发行版可以正常工作,但是v0.19.4发行版不是由于不存在ClipByValue而导致的-对于标记V0.19.3,ClipByValue不在以下非线性之中列出:https://github.com/slundberg/shap/blob/V0.19.3/shap/explainers/deep.py#L44。因此,似乎该特定示例从未与ClipByValue包含在所述数组中一起使用。

要变通解决此问题,我将我的requirements.txt中的shap == v0.21.0替换为

-e git://github.com/slundberg/shap.git@48bc3a7f8fa9465be778ecef14d4de8604275f7f#egg=shap

,然后在我的python virtualenv中,导航到克隆的文件夹,签出一个新的分支,然后在当前位置的顶部粘贴标签V0.19.3的deep.py版本。虽然有点黑...

不确定如何正确解决此问题。