MCPcopy Create free account
hub / github.com/SLDGroup/EMCAD / BasicBlock

Class BasicBlock

lib/resnet.py:32–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30
31
32class BasicBlock(nn.Module):
33 expansion = 1
34
35 def __init__(self, inplanes, planes, stride=1, downsample=None):
36 super(BasicBlock, self).__init__()
37 self.conv1 = conv3x3(inplanes, planes, stride)
38 self.bn1 = nn.BatchNorm2d(planes)
39 self.relu = nn.ReLU(inplace=True)
40 self.conv2 = conv3x3(planes, planes)
41 self.bn2 = nn.BatchNorm2d(planes)
42 self.downsample = downsample
43 self.stride = stride
44
45 def forward(self, x):
46 residual = x
47
48 out = self.conv1(x)
49 out = self.bn1(out)
50 out = self.relu(out)
51
52 out = self.conv2(out)
53 out = self.bn2(out)
54
55 if self.downsample is not None:
56 residual = self.downsample(x)
57
58 out += residual
59 out = self.relu(out)
60
61 return out
62
63
64class Bottleneck(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected