| 77 | expansion: int = 4 |
| 78 | |
| 79 | def __init__( |
| 80 | self, |
| 81 | inplanes: int, |
| 82 | planes: int, |
| 83 | stride: int = 1, |
| 84 | downsample: Optional[nn.Module] = None, |
| 85 | groups: int = 1, |
| 86 | base_width: int = 64, |
| 87 | dilation: int = 1, |
| 88 | norm_layer: Optional[Callable[..., nn.Module]] = None |
| 89 | ) -> None: |
| 90 | super(Bottleneck, self).__init__() |
| 91 | if norm_layer is None: |
| 92 | norm_layer = nn.BatchNorm2d |
| 93 | width = int(planes * (base_width / 64.)) * groups |
| 94 | # Both self.conv2 and self.downsample layers downsample the input when stride != 1 |
| 95 | self.conv1 = conv1x1(inplanes, width) |
| 96 | self.bn1 = norm_layer(width) |
| 97 | self.conv2 = conv3x3(width, width, stride, groups, dilation) |
| 98 | self.bn2 = norm_layer(width) |
| 99 | self.conv3 = conv1x1(width, planes * self.expansion) |
| 100 | self.bn3 = norm_layer(planes * self.expansion) |
| 101 | self.relu = nn.ReLU(inplace=True) |
| 102 | self.downsample = downsample |
| 103 | self.stride = stride |
| 104 | |
| 105 | def forward(self, x: Tensor) -> Tensor: |
| 106 | identity = x |