| 38 | expansion: int = 1 |
| 39 | |
| 40 | def __init__( |
| 41 | self, |
| 42 | inplanes: int, |
| 43 | planes: int, |
| 44 | stride: int = 1, |
| 45 | downsample: Optional[nn.Module] = None, |
| 46 | groups: int = 1, |
| 47 | base_width: int = 64, |
| 48 | dilation: int = 1, |
| 49 | norm_layer: Optional[Callable[..., nn.Module]] = None |
| 50 | ) -> None: |
| 51 | super(BasicBlock, self).__init__() |
| 52 | if norm_layer is None: |
| 53 | norm_layer = nn.BatchNorm2d |
| 54 | if groups != 1 or base_width != 64: |
| 55 | raise ValueError('BasicBlock only supports groups=1 and base_width=64') |
| 56 | if dilation > 1: |
| 57 | raise NotImplementedError("Dilation > 1 not supported in BasicBlock") |
| 58 | # Both self.conv1 and self.downsample layers downsample the input when stride != 1 |
| 59 | self.conv1 = conv3x3(inplanes, planes, stride) |
| 60 | self.bn1 = norm_layer(planes) |
| 61 | self.relu = nn.ReLU(inplace=True) |
| 62 | self.conv2 = conv3x3(planes, planes) |
| 63 | self.bn2 = norm_layer(planes) |
| 64 | self.downsample = downsample |
| 65 | self.stride = stride |
| 66 | |
| 67 | def forward(self, x: Tensor) -> Tensor: |
| 68 | identity = x |