【问题标题】:How to interpret multi-class deep learning classifier by using SHAP?如何使用 SHAP 解释多类深度学习分类器?
【发布时间】: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


    【解决方案1】:

    你是如何导入 keras 的?在执行from keras import... 时,我遇到了同样的问题,但更改为from tensorflow.keras import ... DeepExplainer 工作了

    【讨论】:

      猜你喜欢
      • 2017-05-20
      • 2021-03-31
      • 2021-03-09
      • 2017-01-02
      • 2016-08-21
      • 2021-06-17
      • 2021-12-19
      • 2017-06-11
      相关资源
      最近更新 更多