MCPcopy Create free account
hub / github.com/XLearning-SCU/2022-CVPR-DART / BasicBlock

Class BasicBlock

resnet.py:24–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected