【发布时间】:2020-07-02 03:31:47
【问题描述】:
我在 IRIS 数据集上使用 Keras 训练了一个多类分类器。我想使用SHAP 来解释我的深度学习模型。我使用以下代码行,其中 model 是我经过训练的神经网络分类器,X1[train] 是我的训练输入,X1[test] 是我的测试输入:
import shap
explainer = shap.DeepExplainer(model, X1[train])
shap_values = explainer.shap_values(X1[test])
但是,我得到了这个错误(当我的 softmax 在二进制分类中有一个输出时我很好。当 softmax 有 超过 1 个输出时会出现问题):
ValueError: Unexpectedly found an instance of type `<class 'numpy.ndarray'>`. Expected a symbolic tensor instance.
During handling of the above exception, another exception occurred:
Layer sequential_96 was called with an input that isn't a symbolic tensor. Received type: <class 'numpy.ndarray'>. Full input:
如何解决这个问题并在多类深度学习分类器中获取单个类的 SHAP 值?
【问题讨论】:
标签: tensorflow machine-learning keras deep-learning shap