MCPcopy Create free account
hub / github.com/CausalLearning/robust-unlearnable-examples / BasicBlock

Class BasicBlock

models/resnet.py:10–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10class BasicBlock(nn.Module):
11 expansion = 1
12
13 def __init__(self, in_planes, planes, stride=1, wide=1):
14 super(BasicBlock, self).__init__()
15 planes = planes * wide
16 self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
17 self.bn1 = nn.BatchNorm2d(planes)
18 self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=1, padding=1, bias=False)
19 self.bn2 = nn.BatchNorm2d(planes)
20
21 self.shortcut = nn.Sequential()
22 if stride != 1 or in_planes != self.expansion*planes:
23 self.shortcut = nn.Sequential(
24 nn.Conv2d(in_planes, self.expansion*planes, kernel_size=1, stride=stride, bias=False),
25 nn.BatchNorm2d(self.expansion*planes)
26 )
27
28 def forward(self, x):
29 out = F.relu(self.bn1(self.conv1(x)))
30 out = self.bn2(self.conv2(out))
31 out += self.shortcut(x)
32 out = F.relu(out)
33 return out
34
35
36class Bottleneck(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected