A customized ReLU with the backward pass imputed for guided backpropagation (https://arxiv.org/abs/1412.6806).
| 46 | |
| 47 | |
| 48 | class _GradReLU(torch.nn.Module): |
| 49 | """ |
| 50 | A customized ReLU with the backward pass imputed for guided backpropagation (https://arxiv.org/abs/1412.6806). |
| 51 | """ |
| 52 | |
| 53 | def forward(self, x: torch.Tensor) -> torch.Tensor: |
| 54 | out: torch.Tensor = _AutoGradReLU.apply(x) |
| 55 | return out |
| 56 | |
| 57 | |
| 58 | class VanillaGrad: |