PaddlePaddle / InterpretDL

InterpretDL: Interpretation of Deep Learning Models,基于『飞桨』的模型可解释性算法库。
https://interpretdl.readthedocs.io
Apache License 2.0
237 stars 38 forks source link

Shapely Value #54

Closed AprilDomLin closed 1 year ago

AprilDomLin commented 1 year ago

(optional) Briefly introduce yourself.


❓ Questions and Help

似乎InterpretDL没有提供shapely value的相关计算工具和可视化功能?我没有很了解,是否有大佬能提供帮助和讯息,paddle有没有提供类似的计算方法呀? 主要shap库:https://github.com/slundberg/shap 依赖pytroch,pytroch又跟paddle不兼并。搞的我用paddle训练的模型,无法用shapely value 去做解释说明诶...

holyseven commented 1 year ago

暂时没有shapley的。shapley因为在图像方面计算量较大,最开始并没有计划实现。

模型是什么模型呢?用LIME应该都可以解释,不同的模型有不同的算法可以进行解释。

AprilDomLin commented 1 year ago

暂时没有shapley的。shapley因为在图像方面计算量较大,最开始并没有计划实现。

模型是什么模型呢?用LIME应该都可以解释,不同的模型有不同的算法可以进行解释。

是用的ViT做的分类模型。主要想尝试做解释分析,但是最近看shapely比较多,所以想尝试一下效果。但是我看shap这个库,是可以支持shapely图像的解释欸。 哈哈哈,非常感谢,我再研究一下解释分析吧。

holyseven commented 1 year ago

vanilla ViT结构的话,可以看看这个是否有帮助:https://github.com/PaddlePaddle/InterpretDL/blob/master/examples/example_bt_ga_cv_ViT.ipynb

shapley我们这边再调研和评估一下,要是你有什么想法或者试过哪个算法感觉效果不错,也可以跟分享一下~

AprilDomLin commented 1 year ago

shap:https://github.com/slundberg/shap

之前有用过 这个他主要依赖于pytorch和TensorFlow的库,计算shapely value。可以用于多种机器学习的模型和深度学习模型。

btw,之前有在知乎看到过张拳石老师团队的研究,好像说可以加快在DL中shapely value 的计算。因为不是主要研究解释性的,所以没有挖掘细节。

AprilDomLin commented 1 year ago

这个demo的两个解释方法好像存在问题。报错:AttributeError: 'NoneType' object has no attribute 'numpy'。

我看代码问题,好像是因为注册的hook在backward之前,导致block_attns里面的Tesnor就不存在梯度了。

holyseven commented 1 year ago

我这边没有问题,可以正常运行。Paddle版本:2.3.2

Paddle版本可能出现的问题查看:https://github.com/PaddlePaddle/InterpretDL/pull/51

AprilDomLin commented 1 year ago

谢谢               ·············