Sorry if I asked a stupid question. I thought it was a Spatial Pyramid Pooling (SPP) code but it looks different from what I know. Can someone enlighten me?
def __init__(self, input_channels, output_channels):
super(SPP, self).__init__()
self.Conv1x1 = Conv1x1(input_channels, output_channels)
self.S1 = nn.Sequential(nn.Conv2d(output_channels, output_channels, 5, 1, 2, groups = output_channels, bias = False),
nn.BatchNorm2d(output_channels),
nn.ReLU(inplace=True)
)
self.S2 = nn.Sequential(nn.Conv2d(output_channels, output_channels, 5, 1, 2, groups = output_channels, bias = False),
nn.BatchNorm2d(output_channels),
nn.ReLU(inplace=True),
nn.Conv2d(output_channels, output_channels, 5, 1, 2, groups = output_channels, bias = False),
nn.BatchNorm2d(output_channels),
nn.ReLU(inplace=True)
)
self.S3 = nn.Sequential(nn.Conv2d(output_channels, output_channels, 5, 1, 2, groups = output_channels, bias = False),
nn.BatchNorm2d(output_channels),
nn.ReLU(inplace=True),
nn.Conv2d(output_channels, output_channels, 5, 1, 2, groups = output_channels, bias = False),
nn.BatchNorm2d(output_channels),
nn.ReLU(inplace=True),
nn.Conv2d(output_channels, output_channels, 5, 1, 2, groups = output_channels, bias = False),
nn.BatchNorm2d(output_channels),
nn.ReLU(inplace=True)
)
self.output = nn.Sequential(nn.Conv2d(output_channels * 3, output_channels, 1, 1, 0, bias = False),
nn.BatchNorm2d(output_channels),
)
self.relu = nn.ReLU(inplace=True)
def forward(self, x):
x = self.Conv1x1(x)
y1 = self.S1(x)
y2 = self.S2(x)
y3 = self.S3(x)
y = torch.cat((y1, y2, y3), dim=1)
y = self.relu(x + self.output(y))
return y```