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

Method __init__

clip/model.py:101–124  ·  view source on GitHub ↗
(self, layers, output_dim, heads, input_resolution=224, width=64)

Source from the content-addressed store, hash-verified

99 """
100
101 def __init__(self, layers, output_dim, heads, input_resolution=224, width=64):
102 super().__init__()
103 self.output_dim = output_dim
104 self.input_resolution = input_resolution
105
106 # the 3-layer stem
107 self.conv1 = nn.Conv2d(3, width // 2, kernel_size=3, stride=2, padding=1, bias=False)
108 self.bn1 = nn.BatchNorm2d(width // 2)
109 self.conv2 = nn.Conv2d(width // 2, width // 2, kernel_size=3, padding=1, bias=False)
110 self.bn2 = nn.BatchNorm2d(width // 2)
111 self.conv3 = nn.Conv2d(width // 2, width, kernel_size=3, padding=1, bias=False)
112 self.bn3 = nn.BatchNorm2d(width)
113 self.avgpool = nn.AvgPool2d(2)
114 self.relu = nn.ReLU(inplace=True)
115
116 # residual layers
117 self._inplanes = width # this is a *mutable* variable used during construction
118 self.layer1 = self._make_layer(width, layers[0])
119 self.layer2 = self._make_layer(width * 2, layers[1], stride=2)
120 self.layer3 = self._make_layer(width * 4, layers[2], stride=2)
121 self.layer4 = self._make_layer(width * 8, layers[3], stride=2)
122
123 embed_dim = width * 32 # the ResNet feature dimension
124 self.attnpool = AttentionPool2d(input_resolution // 32, embed_dim, heads, output_dim)
125
126 def _make_layer(self, planes, blocks, stride=1):
127 layers = [Bottleneck(self._inplanes, planes, stride)]

Callers

nothing calls this directly

Calls 3

_make_layerMethod · 0.95
AttentionPool2dClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected