Compute the activation map with upsampling and postprocessing. Args: x: input tensor, shape must be compatible with `nn_module`. class_idx: index of the class to be visualized. Default to argmax(logits) layer_idx: index of the target layer if the
(self, x, class_idx=None, layer_idx=-1, **kwargs)
| 300 | return output.reshape(b, 1, *spatial) # resume the spatial dims on the selected class |
| 301 | |
| 302 | def __call__(self, x, class_idx=None, layer_idx=-1, **kwargs): # type: ignore[override] |
| 303 | """ |
| 304 | Compute the activation map with upsampling and postprocessing. |
| 305 | |
| 306 | Args: |
| 307 | x: input tensor, shape must be compatible with `nn_module`. |
| 308 | class_idx: index of the class to be visualized. Default to argmax(logits) |
| 309 | layer_idx: index of the target layer if there are multiple target layers. Defaults to -1. |
| 310 | kwargs: any extra arguments to be passed on to the module as part of its `__call__`. |
| 311 | |
| 312 | Returns: |
| 313 | activation maps |
| 314 | """ |
| 315 | acti_map = self.compute_map(x, class_idx, layer_idx, **kwargs) |
| 316 | return self._upsample_and_post_process(acti_map, x) |
| 317 | |
| 318 | |
| 319 | class GradCAM(CAMBase): |
nothing calls this directly
no test coverage detected