Skip to content

Commit

Permalink
Merge pull request open-mmlab#25 from yhcao6/vgg
Browse files Browse the repository at this point in the history
add ceil_mode and with_last_pool to vgg
  • Loading branch information
hellock committed Dec 7, 2018
2 parents 95c4afc + 492ca8d commit 1cfe461
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions mmcv/cnn/vgg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ def conv3x3(in_planes, out_planes, dilation=1):
dilation=dilation)


def make_vgg_layer(inplanes, planes, num_blocks, dilation=1, with_bn=False):
def make_vgg_layer(inplanes, planes, num_blocks, dilation=1, with_bn=False,
ceil_mode=False):
layers = []
for _ in range(num_blocks):
layers.append(conv3x3(inplanes, planes, dilation))
if with_bn:
layers.append(nn.BatchNorm2d(planes))
layers.append(nn.ReLU(inplace=True))
inplanes = planes
layers.append(nn.MaxPool2d(kernel_size=2, stride=2))
layers.append(nn.MaxPool2d(kernel_size=2, stride=2, ceil_mode=ceil_mode))

return layers

Expand Down Expand Up @@ -62,7 +63,9 @@ def __init__(self,
out_indices=(0, 1, 2, 3, 4),
frozen_stages=-1,
bn_eval=True,
bn_frozen=False):
bn_frozen=False,
ceil_mode=False,
with_last_pool=True):
super(VGG, self).__init__()
if depth not in self.arch_settings:
raise KeyError('invalid depth {} for vgg'.format(depth))
Expand Down Expand Up @@ -92,11 +95,14 @@ def __init__(self,
planes,
num_blocks,
dilation=dilation,
with_bn=with_bn)
with_bn=with_bn,
ceil_mode=ceil_mode)
vgg_layers.extend(vgg_layer)
self.inplanes = planes
self.range_sub_modules.append([start_idx, end_idx])
start_idx = end_idx
if not with_last_pool:
vgg_layers.pop(-1)
self.module_name = 'features'
self.add_module(self.module_name, nn.Sequential(*vgg_layers))

Expand Down

0 comments on commit 1cfe461

Please sign in to comment.