11
11
# Basic layers
12
12
##########
13
13
class ConvLayer (nn .Module ):
14
-
15
14
"""Convolution layer (conv + bn + relu)."""
16
15
17
16
def __init__ (
@@ -47,7 +46,6 @@ def forward(self, x):
47
46
48
47
49
48
class Conv1x1 (nn .Module ):
50
-
51
49
"""1x1 convolution + bn + relu."""
52
50
53
51
def __init__ (
@@ -76,7 +74,6 @@ def forward(self, x):
76
74
77
75
78
76
class Conv1x1Linear (nn .Module ):
79
-
80
77
"""1x1 convolution + bn (w/o non-linearity)."""
81
78
82
79
def __init__ (self , in_channels , out_channels , stride = 1 , bn = True ):
@@ -96,7 +93,6 @@ def forward(self, x):
96
93
97
94
98
95
class Conv3x3 (nn .Module ):
99
-
100
96
"""3x3 convolution + bn + relu."""
101
97
102
98
def __init__ (self , in_channels , out_channels , stride = 1 , groups = 1 ):
@@ -120,7 +116,6 @@ def forward(self, x):
120
116
121
117
122
118
class LightConv3x3 (nn .Module ):
123
-
124
119
"""Lightweight 3x3 convolution.
125
120
126
121
1x1 (linear) + dw 3x3 (nonlinear).
@@ -151,7 +146,6 @@ def forward(self, x):
151
146
152
147
153
148
class LightConvStream (nn .Module ):
154
-
155
149
"""Lightweight convolution stream."""
156
150
157
151
def __init__ (self , in_channels , out_channels , depth ):
@@ -173,7 +167,6 @@ def forward(self, x):
173
167
# Building blocks for omni-scale feature learning
174
168
##########
175
169
class ChannelGate (nn .Module ):
176
-
177
170
"""A mini-network that generates channel-wise gates conditioned on input tensor."""
178
171
179
172
def __init__ (
@@ -235,7 +228,6 @@ def forward(self, x):
235
228
236
229
237
230
class OSBlock (nn .Module ):
238
-
239
231
"""Omni-scale feature learning block."""
240
232
241
233
def __init__ (self , in_channels , out_channels , reduction = 4 , T = 4 , ** kwargs ):
@@ -269,7 +261,6 @@ def forward(self, x):
269
261
270
262
271
263
class OSBlockINv1 (nn .Module ):
272
-
273
264
"""Omni-scale feature learning block with instance normalization."""
274
265
275
266
def __init__ (self , in_channels , out_channels , reduction = 4 , T = 4 , ** kwargs ):
@@ -305,7 +296,6 @@ def forward(self, x):
305
296
306
297
307
298
class OSBlockINv2 (nn .Module ):
308
-
309
299
"""Omni-scale feature learning block with instance normalization."""
310
300
311
301
def __init__ (self , in_channels , out_channels , reduction = 4 , T = 4 , ** kwargs ):
@@ -341,7 +331,6 @@ def forward(self, x):
341
331
342
332
343
333
class OSBlockINv3 (nn .Module ):
344
-
345
334
"""Omni-scale feature learning block with instance normalization."""
346
335
347
336
def __init__ (self , in_channels , out_channels , reduction = 4 , T = 4 , ** kwargs ):
@@ -379,7 +368,6 @@ def forward(self, x):
379
368
380
369
381
370
class NASBlock (nn .Module ):
382
-
383
371
"""Neural architecture search layer."""
384
372
385
373
def __init__ (self , in_channels , out_channels , search_space = None ):
@@ -425,7 +413,6 @@ def forward(self, x, lmda=1.):
425
413
# Network architecture
426
414
##########
427
415
class OSNet (nn .Module ):
428
-
429
416
"""Omni-Scale Network.
430
417
431
418
Reference:
0 commit comments