MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / Bottleneck

Class Bottleneck

models/resnet.py:56–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54
55
56class Bottleneck(nn.Module):
57 expansion = 4
58
59 def __init__(self, inplanes, planes, stride=1, downsample=None):
60 super(Bottleneck, self).__init__()
61 self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False)
62 self.bn1 = BatchNorm2d(planes)
63 self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride,
64 padding=1, bias=False)
65 self.bn2 = BatchNorm2d(planes)
66 self.conv3 = nn.Conv2d(planes, planes * 4, kernel_size=1, bias=False)
67 self.bn3 = BatchNorm2d(planes * 4)
68 self.relu = nn.ReLU(inplace=True)
69 self.downsample = downsample
70 self.stride = stride
71
72 def forward(self, x):
73 residual = x
74
75 out = self.conv1(x)
76 out = self.bn1(out)
77 out = self.relu(out)
78
79 out = self.conv2(out)
80 out = self.bn2(out)
81 out = self.relu(out)
82
83 out = self.conv3(out)
84 out = self.bn3(out)
85
86 if self.downsample is not None:
87 residual = self.downsample(x)
88
89 out += residual
90 out = self.relu(out)
91
92 return out
93
94
95class ResNet(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected