From 6ff9442c86b16d3118a2672ce4a817d70ced37b5 Mon Sep 17 00:00:00 2001 From: Hank Kung Date: Sat, 24 Aug 2019 17:23:17 +0800 Subject: [PATCH 1/2] Conv implement sep conv should be applied twice and dil_conv sholud be saparated into depth-wise and width-wise --- operations.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/operations.py b/operations.py index 5b08ada..0660129 100755 --- a/operations.py +++ b/operations.py @@ -31,7 +31,8 @@ def __init__(self, C_in, C_out, kernel_size, stride, padding, dilation, affine=T super(DilConv, self).__init__() self.op = nn.Sequential( nn.ReLU(inplace=False), - nn.Conv2d(C_in, C_out, kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, bias=False), + nn.Conv2d(C_in, C_in, kernel_size=kernel_size, stride=stride, padding=padding, groups=C_in, dilation=dilation, bias=False), + nn.Conv2d(C_in, C_out, kernel_size=1, padding=0, bias=False), nn.BatchNorm2d(C_out, affine=affine), ) @@ -46,10 +47,15 @@ def __init__(self, C_in, C_out, kernel_size, stride, padding, affine=True): self.op = nn.Sequential( nn.ReLU(inplace=False), nn.Conv2d(C_in, C_in, kernel_size=kernel_size, stride=stride, padding=padding, groups=C_in, bias=False), + nn.Conv2d(C_in, C_in, kernel_size=1, padding=0, bias=False), + nn.BatchNorm2d(C_in, affine=affine), + nn.ReLU(inplace=False), + nn.Conv2d(C_in, C_in, kernel_size=kernel_size, stride=1, padding=padding, groups=C_in, bias=False), nn.Conv2d(C_in, C_out, kernel_size=1, padding=0, bias=False), nn.BatchNorm2d(C_out, affine=affine), ) + def forward(self, x): return self.op(x) From 43dfab934f6efa9e5250c7f170ca1fe214cf1bfe Mon Sep 17 00:00:00 2001 From: zxzx2999 <853282226@qq.com> Date: Mon, 26 Aug 2019 15:48:14 +0800 Subject: [PATCH 2/2] all FxBx(s/4) --- auto_deeplab.py | 13 +++++++------ cell_level_search.py | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/auto_deeplab.py b/auto_deeplab.py index 79d0d29..8ea217a 100755 --- a/auto_deeplab.py +++ b/auto_deeplab.py @@ -19,7 +19,8 @@ def __init__(self, num_classes, num_layers, criterion = None, filter_multiplier self._filter_multiplier = filter_multiplier self._criterion = criterion self._initialize_alphas_betas () - C_initial = self._filter_multiplier * self._block_multiplier +# C_initial = self._filter_multiplier * self._block_multiplier + C_initial = 128 half_C_initial = int(C_initial / 2) self.stem0 = nn.Sequential( @@ -39,7 +40,7 @@ def __init__(self, num_classes, num_layers, criterion = None, filter_multiplier ) - intitial_fm = C_initial / self._block_multiplier + intitial_fm = C_initial for i in range (self._num_layers) : @@ -139,16 +140,16 @@ def __init__(self, num_classes, num_layers, criterion = None, filter_multiplier self.cells += [cell4] self.aspp_4 = nn.Sequential ( - ASPP (self._block_multiplier * self._filter_multiplier, self._num_classes, 24, 24) #96 / 4 as in the paper + ASPP (self._filter_multiplier, self._num_classes, 24, 24) #96 / 4 as in the paper ) self.aspp_8 = nn.Sequential ( - ASPP (self._block_multiplier * self._filter_multiplier * 2, self._num_classes, 12, 12) #96 / 8 + ASPP (self._filter_multiplier * 2, self._num_classes, 12, 12) #96 / 8 ) self.aspp_16 = nn.Sequential ( - ASPP (self._block_multiplier * self._filter_multiplier * 4, self._num_classes, 6, 6) #96 / 16 + ASPP (self._filter_multiplier * 4, self._num_classes, 6, 6) #96 / 16 ) self.aspp_32 = nn.Sequential ( - ASPP (self._block_multiplier * self._filter_multiplier * 8, self._num_classes, 3, 3) #96 / 32 + ASPP (self._filter_multiplier * 8, self._num_classes, 3, 3) #96 / 32 ) diff --git a/cell_level_search.py b/cell_level_search.py index 3338c17..599f273 100755 --- a/cell_level_search.py +++ b/cell_level_search.py @@ -29,17 +29,23 @@ def __init__(self, steps, block_multiplier, prev_prev_fmultiplier, filter_multiplier): super(Cell, self).__init__() - self.C_in = block_multiplier * filter_multiplier * block_multiplier - self.C_out = filter_multiplier * block_multiplier - self.C_prev_prev = int(prev_prev_fmultiplier * block_multiplier) + # self.C_in = block_multiplier * filter_multiplier * block_multiplier + # self.C_out = filter_multiplier * block_multiplier + self.C_in = block_multiplier * filter_multiplier + self.C_out = filter_multiplier + # self.C_prev_prev = int(prev_prev_fmultiplier * block_multiplier) + self.C_prev_prev = int(prev_prev_fmultiplier) if prev_fmultiplier_down is not None: - self.C_prev_down = int(prev_fmultiplier_down * block_multiplier) + # self.C_prev_down = int(prev_fmultiplier_down * block_multiplier) + self.C_prev_down = prev_fmultiplier_down self.preprocess_down = FactorizedReduce(self.C_prev_down, self.C_out, affine=False) if prev_fmultiplier_same is not None: - self.C_prev_same = int(prev_fmultiplier_same * block_multiplier) + # self.C_prev_same = int(prev_fmultiplier_same * block_multiplier) + self.C_prev_same = prev_fmultiplier_same self.preprocess_same = ReLUConvBN(self.C_prev_same, self.C_out, 1, 1, 0, affine=False) if prev_fmultiplier_up is not None: - self.C_prev_up = int(prev_fmultiplier_up * block_multiplier) + # self.C_prev_up = int(prev_fmultiplier_up * block_multiplier) + self.C_prev_up = prev_fmultiplier_up self.preprocess_up = FactorizedIncrease(self.C_prev_up, self.C_out)