Skip to content

Commit 7a4f0aa

Browse files
authored
Merge pull request #53 from ayasyrev/rename_se_layers
se module rename at repr
2 parents a31a450 + 50f242a commit 7a4f0aa

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

model_constructor/layers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ def __init__(self,
204204
rd_channels = max(rd_channels, reducted)
205205
self.squeeze = nn.AdaptiveAvgPool2d(1)
206206
self.excitation = nn.Sequential(
207-
OrderedDict([('fc_reduce', se_layer(channels, rd_channels, bias=use_bias)),
207+
OrderedDict([('reduce', se_layer(channels, rd_channels, bias=use_bias)),
208208
('se_act', act_fn),
209-
('fc_expand', se_layer(rd_channels, channels, bias=use_bias)),
209+
('expand', se_layer(rd_channels, channels, bias=use_bias)),
210210
('se_gate', gate())
211211
]))
212212

@@ -241,9 +241,9 @@ def __init__(self,
241241
self.squeeze = nn.AdaptiveAvgPool2d(1)
242242
self.excitation = nn.Sequential(
243243
OrderedDict([
244-
('conv_reduce', se_layer(channels, rd_channels, 1, bias=use_bias)),
244+
('reduce', se_layer(channels, rd_channels, 1, bias=use_bias)),
245245
('se_act', act_fn),
246-
('conv_expand', se_layer(rd_channels, channels, 1, bias=use_bias)),
246+
('expand', se_layer(rd_channels, channels, 1, bias=use_bias)),
247247
('gate', gate())
248248
]))
249249

model_constructor/model_constructor.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,17 @@ def _make_stem(self):
8686
return nn.Sequential(OrderedDict(stem))
8787

8888

89-
def _make_layer(self, layer_id: int) -> nn.Module:
89+
def _make_layer(self, layer_num: int) -> nn.Module:
9090
# expansion, in_channels, out_channels, blocks, stride, sa):
91-
stride = 1 if self.stem_pool and layer_id == 0 else 2 # if no pool on stem - stride = 2 for first layer block in body
92-
num_blocks = self.layers[layer_id]
91+
stride = 1 if self.stem_pool and layer_num == 0 else 2 # if no pool on stem - stride = 2 for first layer block in body
92+
num_blocks = self.layers[layer_num]
9393
return nn.Sequential(OrderedDict([
9494
(f"bl_{block_num}", self.block(
9595
self.expansion,
96-
self.block_sizes[layer_id] if block_num == 0 else self.block_sizes[layer_id + 1],
97-
self.block_sizes[layer_id + 1],
96+
self.block_sizes[layer_num] if block_num == 0 else self.block_sizes[layer_num + 1],
97+
self.block_sizes[layer_num + 1],
9898
stride if block_num == 0 else 1,
99-
sa=self.sa if block_num == num_blocks - 1 else None,
99+
sa=self.sa if (block_num == num_blocks - 1) and layer_num == 0 else None,
100100
conv_layer=self.conv_layer,
101101
act_fn=self.act_fn,
102102
pool=self.pool,
@@ -169,7 +169,7 @@ def __init__(self, name='MC', in_chans=3, num_classes=1000,
169169
else:
170170
self.sa = sa
171171
if self.se_module or se_reduction: # pragma: no cover
172-
print("Deprecated. Pass se_module as se argument, se_reduction as arg to se.") # add deprecation worning.
172+
print("Deprecated. Pass se_module as se argument, se_reduction as arg to se.") # add deprecation warning.
173173

174174
@property
175175
def block_sizes(self):

0 commit comments

Comments
 (0)