'SHAP explainer identifies wrong framework
I want to use the SHAP-DeepInterpeter on the Braindecode Shallow_FBCSP-Model which is based on pytorch.
The training and testing works perfectly fine on the model but when I try to pass the model to SHAP it somehow recognize the tensorflow framework and not the pytorch framework.
For Code:
e = shap.DeepExplainer(model, background)
I get following Error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-63-9c7a102b5020> in <module>
32 print(type(model))
33
---> 34 e = shap.DeepExplainer(model, background)
35 #shap_values = e.shap_values(test_images)
~\miniconda3\envs\braindecode\lib\site-packages\shap\explainers\_deep\__init__.py in __init__(self, model, data, session, learning_phase_flags)
82
83 if framework == 'tensorflow':
---> 84 self.explainer = TFDeep(model, data, session, learning_phase_flags)
85 elif framework == 'pytorch':
86 self.explainer = PyTorchDeep(model, data)
~\miniconda3\envs\braindecode\lib\site-packages\shap\explainers\_deep\deep_tf.py in __init__(self, model, data, session, learning_phase_flags)
76 global tf, tf_ops, tf_backprop, tf_execute, tf_gradients_impl
77 if tf is None:
---> 78 from tensorflow.python.framework import ops as tf_ops # pylint: disable=E0611
79 from tensorflow.python.ops import gradients_impl as tf_gradients_impl # pylint: disable=E0611
80 from tensorflow.python.eager import backprop as tf_backprop
ModuleNotFoundError: No module named 'tensorflow'
As said my Model has the type
<class 'braindecode.models.shallow_fbcsp.ShallowFBCSPNet'>
Has someone an idea what I missed ?
Thanks in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|