MCPcopy Create free account
hub / github.com/ActiveVisionLab/DFNet / __init__

Method __init__

script/feature/dfnet.py:46–64  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

44 """
45
46 def __init__(self, hypercolumn_layers: List[str], output_dim: int = 128):
47 """Initialize one adaptation layer for every extraction point.
48
49 Args:
50 hypercolumn_layers: The list of the hypercolumn layer names.
51 output_dim: The output channel dimension.
52 """
53 super(AdaptLayers, self).__init__()
54 self.layers = []
55 channel_sizes = [vgg16_layers[name] for name in hypercolumn_layers]
56 for i, l in enumerate(channel_sizes):
57 layer = nn.Sequential(
58 nn.Conv2d(l, 64, kernel_size=1, stride=1, padding=0),
59 nn.ReLU(),
60 nn.Conv2d(64, output_dim, kernel_size=5, stride=1, padding=2),
61 nn.BatchNorm2d(output_dim),
62 )
63 self.layers.append(layer)
64 self.add_module("adapt_layer_{}".format(i), layer) # ex: adapt_layer_0
65
66 def forward(self, features: List[torch.tensor]):
67 """Apply adaptation layers. # here is list of three levels of features

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected