| 14 | |
| 15 | |
| 16 | class BasicBlock(nn.Module): |
| 17 | expansion = 1 |
| 18 | |
| 19 | def __init__(self, in_planes, planes, stride=1): |
| 20 | super(BasicBlock, self).__init__() |
| 21 | self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, stride=stride, padding=1, bias=False) |
| 22 | self.bn1 = nn.BatchNorm2d(planes) |
| 23 | self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=1, padding=1, bias=False) |
| 24 | self.bn2 = nn.BatchNorm2d(planes) |
| 25 | |
| 26 | self.shortcut = nn.Sequential() |
| 27 | if stride != 1 or in_planes != self.expansion*planes: |
| 28 | self.shortcut = nn.Sequential( |
| 29 | nn.Conv2d(in_planes, self.expansion*planes, kernel_size=1, stride=stride, bias=False), |
| 30 | nn.BatchNorm2d(self.expansion*planes) |
| 31 | ) |
| 32 | |
| 33 | def forward(self, x): |
| 34 | out = F.relu(self.bn1(self.conv1(x))) |
| 35 | out = self.bn2(self.conv2(out)) |
| 36 | out += self.shortcut(x) |
| 37 | out = F.relu(out) |
| 38 | return out |
| 39 | |
| 40 | class Bottleneck(nn.Module): |
| 41 | expansion = 4 |
nothing calls this directly
no outgoing calls
no test coverage detected