Using Captum to interpret models
Captum (https://captum.ai/) is an open source model interpretability library built by Facebook on top of PyTorch, and it is currently (at the time of writing) under active development. In this section, we will use the handwritten digits classification model that we had trained in the preceding section. We will also use some of the model interpretability tools offered by Captum to explain the predictions made by this model. The full code for the following exercise can be found here: https://github.com/PacktPublishing/Mastering-PyTorch/blob/master/Chapter13/captum_interpretability.ipynb.
Setting up Captum
The model training code is similar to the code shown under the Training the handwritten digits classifier – a recap section. In the following steps, we will use the trained model and a sample image to understand what happens inside the model while making a prediction for the given image:
- There are few extra imports related to Captum...