(self, layers, output_dim, heads, input_resolution=224, width=64)
| 100 | """ |
| 101 | |
| 102 | def __init__(self, layers, output_dim, heads, input_resolution=224, width=64): |
| 103 | super().__init__() |
| 104 | self.output_dim = output_dim |
| 105 | self.input_resolution = input_resolution |
| 106 | |
| 107 | # the 3-layer stem |
| 108 | self.conv1 = nn.Conv2d(3, width // 2, kernel_size=3, stride=2, padding=1, bias=False) |
| 109 | self.bn1 = nn.BatchNorm2d(width // 2) |
| 110 | self.relu1 = nn.ReLU(inplace=True) |
| 111 | self.conv2 = nn.Conv2d(width // 2, width // 2, kernel_size=3, padding=1, bias=False) |
| 112 | self.bn2 = nn.BatchNorm2d(width // 2) |
| 113 | self.relu2 = nn.ReLU(inplace=True) |
| 114 | self.conv3 = nn.Conv2d(width // 2, width, kernel_size=3, padding=1, bias=False) |
| 115 | self.bn3 = nn.BatchNorm2d(width) |
| 116 | self.relu3 = nn.ReLU(inplace=True) |
| 117 | self.avgpool = nn.AvgPool2d(2) |
| 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)] |
nothing calls this directly
no test coverage detected