# Codeblock 6 class InvResidualS2(nn.Module): def __init__(self, in_channels, out_channels, t): #(1) super().__init__() in_channels = int(in_channels*WIDTH_MULTIPLIER) #(2) out_channels = int(out_channels*WIDTH_MULTIPLIER) #(3) self.pwconv0 = nn.Conv2d(in_channels=in_channels, #(4) out_channels=in_channels*t, kernel_size=1, stride=1, bias=False) self.bn_pwconv0 = nn.BatchNorm2d(num_features=in_channels*t) self.dwconv = nn.Conv2d(in_channels=in_channels*t, #(5) out_channels=in_channels*t, kernel_size=3, #(6) stride=2, padding=1, groups=in_channels*t, #(7) bias=False) self.bn_dwconv = nn.BatchNorm2d(num_features=in_channels*t) self.pwconv1 = nn.Conv2d(in_channels=in_channels*t, #(8) out_channels=out_channels, kernel_size=1, stride=1, bias=False) self.bn_pwconv1 = nn.BatchNorm2d(num_features=out_channels) self.relu6 = nn.ReLU6() def forward(self, x): print('original\t\t:', x.shape) x = self.pwconv0(x) print('after pwconv0\t\t:', x.shape) x = self.bn_pwconv0(x) print('after bn0_pwconv0\t:', x.shape) x = self.relu6(x) print('after relu\t\t:', x.shape) x = self.dwconv(x) print('after dwconv\t\t:', x.shape) x = self.bn_dwconv(x) print('after bn_dwconv\t\t:', x.shape) x = self.relu6(x) print('after relu\t\t:', x.shape) x = self.pwconv1(x) print('after pwconv1\t\t:', x.shape) x = self.bn_pwconv1(x) print('after bn_pwconv1\t:', x.shape) return x