MCPcopy Create free account
hub / github.com/CHENGY12/PLOT / __init__

Method __init__

plot-pp/clip/model.py:104–127  ·  view source on GitHub ↗
(self, layers, output_dim, heads, input_resolution=224, width=64)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

_make_layerMethod · 0.95
AttentionPool2dClass · 0.70
__init__Method · 0.45

Tested by

no test coverage detected