如何在Cifar10数据集上修复Shap解释程序?

2024-09-26 22:51:41 发布

您现在位置:Python中文网/ 问答频道 /正文

当前正在尝试实现如下所示的shap解释程序:“https://slundberg.github.io/shap/notebooks/deep_explainer/Front%20Page%20DeepExplainer%20MNIST%20Example.html”,除了在Cifar10数据集上

我的原始图像不显示在左侧,结果是黑色方块。下面的其他图片似乎在工作

代码基本上与他们使用的相同,所以我不确定出了什么问题(可能与RGB有关?)

import shap
import numpy as np

# select a set of background examples to take an expectation over
background = x_train[np.random.choice(x_train.shape[0], 100, replace=False)]

# explain predictions of the model
e = shap.DeepExplainer(model, background)
shap_values = e.shap_values(x_test[1:5])

shap.image_plot(shap_values, -x_test[1:5])

Tags: ofhttpsiotestimportgithubmodelnp

热门问题