MCPcopy Create free account
hub / github.com/SLDGroup/EMCAD / __init__

Method __init__

lib/decoders.py:117–154  ·  view source on GitHub ↗
(self, in_channels, out_channels, stride, kernel_sizes=[1,3,5], expansion_factor=2, dw_parallel=True, add=True, activation='relu6')

Source from the content-addressed store, hash-verified

115 Multi-scale convolution block (MSCB)
116 """
117 def __init__(self, in_channels, out_channels, stride, kernel_sizes=[1,3,5], expansion_factor=2, dw_parallel=True, add=True, activation='relu6'):
118 super(MSCB, self).__init__()
119
120 self.in_channels = in_channels
121 self.out_channels = out_channels
122 self.stride = stride
123 self.kernel_sizes = kernel_sizes
124 self.expansion_factor = expansion_factor
125 self.dw_parallel = dw_parallel
126 self.add = add
127 self.activation = activation
128 self.n_scales = len(self.kernel_sizes)
129 # check stride value
130 assert self.stride in [1, 2]
131 # Skip connection if stride is 1
132 self.use_skip_connection = True if self.stride == 1 else False
133
134 # expansion factor
135 self.ex_channels = int(self.in_channels * self.expansion_factor)
136 self.pconv1 = nn.Sequential(
137 # pointwise convolution
138 nn.Conv2d(self.in_channels, self.ex_channels, 1, 1, 0, bias=False),
139 nn.BatchNorm2d(self.ex_channels),
140 act_layer(self.activation, inplace=True)
141 )
142 self.msdc = MSDC(self.ex_channels, self.kernel_sizes, self.stride, self.activation, dw_parallel=self.dw_parallel)
143 if self.add == True:
144 self.combined_channels = self.ex_channels*1
145 else:
146 self.combined_channels = self.ex_channels*self.n_scales
147 self.pconv2 = nn.Sequential(
148 # pointwise convolution
149 nn.Conv2d(self.combined_channels, self.out_channels, 1, 1, 0, bias=False),
150 nn.BatchNorm2d(self.out_channels),
151 )
152 if self.use_skip_connection and (self.in_channels != self.out_channels):
153 self.conv1x1 = nn.Conv2d(self.in_channels, self.out_channels, 1, 1, 0, bias=False)
154 self.init_weights('normal')
155
156 def init_weights(self, scheme=''):
157 named_apply(partial(_init_weights, scheme=scheme), self)

Callers

nothing calls this directly

Calls 4

init_weightsMethod · 0.95
act_layerFunction · 0.85
MSDCClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected