MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / GlobalFeatureExtractor

Class GlobalFeatureExtractor

segmentation/backbones/fast_scnn.py:83–192  ·  view source on GitHub ↗

Global feature extractor module. Args: in_channels (int): Number of input channels of the GFE module. Default: 64 block_channels (tuple[int]): Tuple of ints. Each int specifies the number of output channels of each Inverted Residual module. De

Source from the content-addressed store, hash-verified

81
82
83class GlobalFeatureExtractor(nn.Module):
84 """Global feature extractor module.
85
86 Args:
87 in_channels (int): Number of input channels of the GFE module.
88 Default: 64
89 block_channels (tuple[int]): Tuple of ints. Each int specifies the
90 number of output channels of each Inverted Residual module.
91 Default: (64, 96, 128)
92 out_channels(int): Number of output channels of the GFE module.
93 Default: 128
94 expand_ratio (int): Adjusts number of channels of the hidden layer
95 in InvertedResidual by this amount.
96 Default: 6
97 num_blocks (tuple[int]): Tuple of ints. Each int specifies the
98 number of times each Inverted Residual module is repeated.
99 The repeated Inverted Residual modules are called a 'group'.
100 Default: (3, 3, 3)
101 strides (tuple[int]): Tuple of ints. Each int specifies
102 the downsampling factor of each 'group'.
103 Default: (2, 2, 1)
104 pool_scales (tuple[int]): Tuple of ints. Each int specifies
105 the parameter required in 'global average pooling' within PPM.
106 Default: (1, 2, 3, 6)
107 conv_cfg (dict | None): Config of conv layers. Default: None
108 norm_cfg (dict | None): Config of norm layers. Default:
109 dict(type='BN')
110 act_cfg (dict): Config of activation layers. Default:
111 dict(type='ReLU')
112 align_corners (bool): align_corners argument of F.interpolate.
113 Default: False
114 """
115
116 def __init__(self,
117 in_channels=64,
118 block_channels=(64, 96, 128),
119 out_channels=128,
120 expand_ratio=6,
121 num_blocks=(3, 3, 3),
122 strides=(2, 2, 1),
123 pool_scales=(1, 2, 3, 6),
124 conv_cfg=None,
125 norm_cfg=dict(type='BN'),
126 act_cfg=dict(type='ReLU'),
127 align_corners=False):
128 super(GlobalFeatureExtractor, self).__init__()
129 self.conv_cfg = conv_cfg
130 self.norm_cfg = norm_cfg
131 self.act_cfg = act_cfg
132 assert len(block_channels) == len(num_blocks) == 3
133 self.bottleneck1 = self._make_layer(in_channels, block_channels[0],
134 num_blocks[0], strides[0],
135 expand_ratio)
136 self.bottleneck2 = self._make_layer(block_channels[0],
137 block_channels[1], num_blocks[1],
138 strides[1], expand_ratio)
139 self.bottleneck3 = self._make_layer(block_channels[1],
140 block_channels[2], num_blocks[2],

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected