We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update 0.45.0 has a breaking change
After the update, the pytorch example in the documentation process shap_values incorrectly https://shap.readthedocs.io/en/latest/example_notebooks/image_examples/image_classification/PyTorch%20Deep%20Explainer%20MNIST%20example.html
shap_numpy = [np.swapaxes(np.swapaxes(s, 1, -1), 1, 2) for s in shap_values] test_numpy = np.swapaxes(np.swapaxes(test_images.numpy(), 1, -1), 1, 2)
Causing an error in the following code
# plot the feature attributions shap.image_plot(list(shap_numpy), -test_numpy)
Updating the processing of output to the following version should resolve the issue
# shap_numpy = [np.swapaxes(np.swapaxes(s, 1, -1), 1, 2) for s in shap_values] shap_numpy = list(np.transpose(shap_values, (4, 0, 2, 3, 1))) test_numpy = np.swapaxes(np.swapaxes(test_images.numpy(), 1, -1), 1, 2)
See above
IndexError Traceback (most recent call last) Cell In[17], line 2 1 # plot the feature attributions ----> 2 shap.image_plot(list(shap_numpy), -test_numpy) File ~/miniconda3/envs/iiot/lib/python3.11/site-packages/shap/plots/_image.py:154, in image(shap_values, pixel_values, labels, true_labels, width, aspect, hspace, labelpad, cmap, show) 152 axes[row, 0].set_title(true_labels[row], **label_kwargs) 153 axes[row, 0].axis('off') --> 154 if len(shap_values[0][row].shape) == 2: 155 abs_vals = np.stack([np.abs(shap_values[i]) for i in range(len(shap_values))], 0).flatten() 156 else: IndexError: index 1 is out of bounds for axis 0 with size 1
No response
0.45.0
The text was updated successfully, but these errors were encountered:
Thanks for reporting and a special thanks for figuring out a solution. I created a PR using exactly the code you suggested.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Issue Description
Update 0.45.0 has a breaking change
After the update, the pytorch example in the documentation process shap_values incorrectly
https://shap.readthedocs.io/en/latest/example_notebooks/image_examples/image_classification/PyTorch%20Deep%20Explainer%20MNIST%20example.html
Causing an error in the following code
Updating the processing of output to the following version should resolve the issue
Minimal Reproducible Example
See above
Traceback
Expected Behavior
No response
Bug report checklist
Installed Versions
0.45.0
The text was updated successfully, but these errors were encountered: