MCPcopy Create free account
hub / github.com/Mattdl/ContinualPrototypeEvolution / BasicBlock

Class BasicBlock

model/common.py:48–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47
48class BasicBlock(nn.Module):
49 expansion = 1
50
51 def __init__(self, in_planes, planes, stride=1):
52 super(BasicBlock, self).__init__()
53 self.conv1 = conv3x3(in_planes, planes, stride)
54 self.bn1 = nn.BatchNorm2d(planes)
55 self.conv2 = conv3x3(planes, planes)
56 self.bn2 = nn.BatchNorm2d(planes)
57
58 self.shortcut = nn.Sequential()
59 if stride != 1 or in_planes != self.expansion * planes:
60 self.shortcut = nn.Sequential(
61 nn.Conv2d(in_planes, self.expansion * planes, kernel_size=1,
62 stride=stride, bias=False),
63 nn.BatchNorm2d(self.expansion * planes)
64 )
65
66 def forward(self, x):
67 out = relu(self.bn1(self.conv1(x)))
68 out = self.bn2(self.conv2(out))
69 out += self.shortcut(x)
70 out = relu(out)
71 return out
72
73
74class ResNet(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected