Computes the actual feature map size given `nn_module` and the target_layer name. Args: input_size: shape of the input tensor device: the device used to initialise the input tensor layer_idx: index of the target layer if there are multiple target
(self, input_size, device="cpu", layer_idx=-1, **kwargs)
| 179 | self.postprocessing = postprocessing |
| 180 | |
| 181 | def feature_map_size(self, input_size, device="cpu", layer_idx=-1, **kwargs): |
| 182 | """ |
| 183 | Computes the actual feature map size given `nn_module` and the target_layer name. |
| 184 | Args: |
| 185 | input_size: shape of the input tensor |
| 186 | device: the device used to initialise the input tensor |
| 187 | layer_idx: index of the target layer if there are multiple target layers. Defaults to -1. |
| 188 | kwargs: any extra arguments to be passed on to the module as part of its `__call__`. |
| 189 | Returns: |
| 190 | shape of the actual feature map. |
| 191 | """ |
| 192 | return self.compute_map(torch.zeros(*input_size, device=device), layer_idx=layer_idx, **kwargs).shape |
| 193 | |
| 194 | def compute_map(self, x, class_idx=None, layer_idx=-1): |
| 195 | """ |