alibi icon indicating copy to clipboard operation
alibi copied to clipboard

Cannot import alibi on google colab

Open tousif47 opened this issue 6 years ago • 2 comments

Tried to run Integrated gradients for a ResNet model trained on Imagenet dataset on google colab. But getting error while importing "from alibi.explainers import IntegratedGradients". I have installed the alibi manually. Here's the code" https://colab.research.google.com/drive/1IGft4ywCZdugtHBcrb-41cAtsPdyER-h?usp=sharing

Here's the error: ModuleNotFoundError Traceback (most recent call last)

in () 4 import tensorflow as tf 5 import matplotlib.pyplot as plt ----> 6 from alibi.explainers import IntegratedGradients 7 from tensorflow.keras.applications.resnet_v2 import ResNet50V2 8 from alibi.datasets import fetch_imagenet

ModuleNotFoundError: No module named 'alibi'


NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the "Open Examples" button below.

Would be nice to know what am I doing wrong. Thanks

tousif47 avatar Aug 28 '20 01:08 tousif47

Apparently shap did API changes not in a backwards compatible manner without changing the MAJOR version (see https://semver.org/), so colab installs the version 0.36.x that doesn't have the subpackage shap.common.

The solution is to install the version 0.35.0 with: ! pip uninstall shap ! pip install shap==0.35.0

I suggest to update https://github.com/SeldonIO/alibi/blob/master/requirements/requirements.txt with shap~=0.35.0 (note the '~' instead of '>').

franco-ruggeri avatar Aug 28 '20 14:08 franco-ruggeri

Apparently shap did API changes not in a backwards compatible manner without changing the MAJOR version (see https://semver.org/), so colab installs the version 0.36.x that doesn't have the subpackage shap.common.

The solution is to install the version 0.35.0 with: ! pip uninstall shap ! pip install shap==0.35.0

I suggest to update https://github.com/SeldonIO/alibi/blob/master/requirements/requirements.txt with shap~=0.35.0 (note the '~' instead of '>').

Thanks, its working now

tousif47 avatar Aug 28 '20 14:08 tousif47