Replace EmptyLayer with nn.Sequential (#420)

* Replace EmptyLayer with nn.Sequential

* Update models.py

* Update models.py
This commit is contained in:
Yonghye Kwon 2019-08-03 20:24:14 +09:00 committed by Glenn Jocher
parent 267b4301e2
commit 333cf92bb2
1 changed files with 2 additions and 13 deletions

View File

@ -51,14 +51,13 @@ def create_modules(module_defs):
elif module_def['type'] == 'route':
layers = [int(x) for x in module_def['layers'].split(',')]
filters = sum([output_filters[i + 1 if i > 0 else i] for i in layers])
modules.add_module('route_%d' % i, EmptyLayer())
modules.add_module('route_%d' % i, nn.Sequential()) # Placeholder for 'route' layer
# if module_defs[i+1]['type'] == 'reorg3d':
# upsample = nn.Upsample(scale_factor=1/float(module_defs[i+1]['stride']), mode='nearest')
# modules.add_module('reorg3d_%d' % i, upsample)
elif module_def['type'] == 'shortcut':
filters = output_filters[int(module_def['from'])]
modules.add_module('shortcut_%d' % i, EmptyLayer())
modules.add_module('shortcut_%d' % i, nn.Sequential()) # Placeholder for 'shortcut' layer
elif module_def['type'] == 'reorg3d':
# torch.Size([16, 128, 104, 104])
@ -86,16 +85,6 @@ def create_modules(module_defs):
return hyperparams, module_list
class EmptyLayer(nn.Module):
"""Placeholder for 'route' and 'shortcut' layers"""
def __init__(self):
super(EmptyLayer, self).__init__()
def forward(self, x):
return x
class YOLOLayer(nn.Module):
def __init__(self, anchors, nc, img_size, yolo_index):
super(YOLOLayer, self).__init__()