From e071b8dd3a68b5ebc25361f0aac290b295f99796 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 24 Jun 2020 13:12:23 -0700 Subject: [PATCH] update models/common.py for Conv() flexible padding --- models/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/common.py b/models/common.py index 10f6fd6..3c4a0d7 100644 --- a/models/common.py +++ b/models/common.py @@ -13,7 +13,8 @@ class Conv(nn.Module): # Standard convolution def __init__(self, c1, c2, k=1, s=1, g=1, act=True): # ch_in, ch_out, kernel, stride, groups super(Conv, self).__init__() - self.conv = nn.Conv2d(c1, c2, k, s, k // 2, groups=g, bias=False) + p = k // 2 if isinstance(k, int) else [x // 2 for x in k] # padding + self.conv = nn.Conv2d(c1, c2, k, s, p, groups=g, bias=False) self.bn = nn.BatchNorm2d(c2) self.act = nn.LeakyReLU(0.1, inplace=True) if act else nn.Identity()