| 48 | expansion = 1 |
| 49 | |
| 50 | def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1, |
| 51 | base_width=64, dilation=1, norm_layer=None): |
| 52 | super(BasicBlock, self).__init__() |
| 53 | if norm_layer is None: |
| 54 | norm_layer = nn.BatchNorm2d |
| 55 | if groups != 1 or base_width != 64: |
| 56 | raise ValueError( |
| 57 | 'BasicBlock only supports groups=1 and base_width=64') |
| 58 | if dilation > 1: |
| 59 | raise NotImplementedError( |
| 60 | "Dilation > 1 not supported in BasicBlock") |
| 61 | # Both self.conv1 and self.downsample layers downsample the input when stride != 1 |
| 62 | self.conv1 = conv3x3(inplanes, planes, stride) |
| 63 | self.bn1 = norm_layer(planes) |
| 64 | self.relu = nn.ReLU(inplace=False) |
| 65 | self.conv2 = conv3x3(planes, planes) |
| 66 | self.bn2 = norm_layer(planes) |
| 67 | self.downsample = downsample |
| 68 | self.stride = stride |
| 69 | |
| 70 | def forward(self, x): |
| 71 | identity = x |