MCPcopy Create free account
hub / github.com/Monalissaa/DisenDiff / __init__

Method __init__

clip/model.py:13–38  ·  view source on GitHub ↗
(self, inplanes, planes, stride=1)

Source from the content-addressed store, hash-verified

11 expansion = 4
12
13 def __init__(self, inplanes, planes, stride=1):
14 super().__init__()
15
16 # all conv layers have stride 1. an avgpool is performed after the second convolution when stride > 1
17 self.conv1 = nn.Conv2d(inplanes, planes, 1, bias=False)
18 self.bn1 = nn.BatchNorm2d(planes)
19
20 self.conv2 = nn.Conv2d(planes, planes, 3, padding=1, bias=False)
21 self.bn2 = nn.BatchNorm2d(planes)
22
23 self.avgpool = nn.AvgPool2d(stride) if stride > 1 else nn.Identity()
24
25 self.conv3 = nn.Conv2d(planes, planes * self.expansion, 1, bias=False)
26 self.bn3 = nn.BatchNorm2d(planes * self.expansion)
27
28 self.relu = nn.ReLU(inplace=True)
29 self.downsample = None
30 self.stride = stride
31
32 if stride > 1 or inplanes != planes * Bottleneck.expansion:
33 # downsampling layer is prepended with an avgpool, and the subsequent convolution has stride 1
34 self.downsample = nn.Sequential(OrderedDict([
35 ("-1", nn.AvgPool2d(stride)),
36 ("0", nn.Conv2d(inplanes, planes * self.expansion, 1, stride=1, bias=False)),
37 ("1", nn.BatchNorm2d(planes * self.expansion))
38 ]))
39
40 def forward(self, x: torch.Tensor):
41 identity = x

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected