@@ -97,7 +97,7 @@ The aim is also to serve as a benchmark of algorithms and metrics for research o
97
97
98
98
----------
99
99
# Choosing the Target Layer
100
- You need to choose the target layer to compute CAM for.
100
+ You need to choose the target layer to compute the CAM for.
101
101
Some common choices are:
102
102
- FasterRCNN: model.backbone
103
103
- Resnet18 and 50: model.layer4[ -1]
@@ -143,7 +143,7 @@ with GradCAM(model=model, target_layers=target_layers) as cam:
143
143
model_outputs = cam.outputs
144
144
```
145
145
146
- Cam .py has a more detailed usage example.
146
+ cam .py has a more detailed usage example.
147
147
148
148
----------
149
149
@@ -176,7 +176,7 @@ scores = cam_metric(input_tensor, grayscale_cams, targets, model)
176
176
----------
177
177
178
178
179
- # Advanced use cases and tutorials:
179
+ # Adapting for new architectures and tasks
180
180
181
181
Methods like GradCAM were designed for and were originally mostly applied on classification models,
182
182
and specifically CNN classification models.
@@ -186,15 +186,15 @@ The be able to adapt to non standard cases, we have two concepts.
186
186
- The reshape transform - how do we convert activations to represent spatial images ?
187
187
- The model targets - What exactly should the explainability method try to explain ?
188
188
189
- ## The reshape transform
189
+ ## The reshape_transform argument
190
190
In a CNN the intermediate activations in the model are a mult-channel image that have the dimensions channel x rows x cols,
191
191
and the various explainabiltiy methods work with these to produce a new image.
192
192
193
193
In case of another architecture, like the Vision Transformer, the shape might be different, like (rows x cols + 1) x channels, or something else.
194
194
The reshape transform converts the activations back into a multi-channel image, for example by removing the class token in a vision transformer.
195
195
For examples, check [ here] ( https://github.com/jacobgil/pytorch-grad-cam/blob/master/pytorch_grad_cam/utils/reshape_transforms.py )
196
196
197
- ## Model Targets
197
+ ## The model_target argument
198
198
The model target is just a callable that is able to get the model output, and filter it out for the specific scalar output we want to explain.
199
199
200
200
For classification tasks, the model target will typically be the output from a specific category.
0 commit comments