Initialize one adaptation layer for every extraction point. Args: hypercolumn_layers: The list of the hypercolumn layer names. output_dim: The output channel dimension.
(self, hypercolumn_layers: List[str], output_dim: int = 128)
| 151 | """ |
| 152 | |
| 153 | def __init__(self, hypercolumn_layers: List[str], output_dim: int = 128): |
| 154 | """Initialize one adaptation layer for every extraction point. |
| 155 | |
| 156 | Args: |
| 157 | hypercolumn_layers: The list of the hypercolumn layer names. |
| 158 | output_dim: The output channel dimension. |
| 159 | """ |
| 160 | super(AdaptLayers2, self).__init__() |
| 161 | self.layers = [] |
| 162 | channel_sizes = [EB0_layers[name] for name in hypercolumn_layers] |
| 163 | for i, l in enumerate(channel_sizes): |
| 164 | layer = nn.Sequential( |
| 165 | nn.Conv2d(l, 64, kernel_size=1, stride=1, padding=0), |
| 166 | nn.ReLU(), |
| 167 | nn.Conv2d(64, output_dim, kernel_size=5, stride=1, padding=2), |
| 168 | nn.BatchNorm2d(output_dim), |
| 169 | ) |
| 170 | self.layers.append(layer) |
| 171 | self.add_module("adapt_layer_{}".format(i), layer) # ex: adapt_layer_0 |
| 172 | |
| 173 | def forward(self, features: List[torch.tensor]): |
| 174 | """Apply adaptation layers. # here is list of three levels of features |