Concatenating branches(of different dimensions) of googlenet on Pytorch
is there any way I can concatenate branches of different dimensions of a small inception(googlenet)?
For example, at a 32 x 32 x 3 image (torch.Size([1, 3, 32, 32])), it will pass through an inception module with the following branches:

a convolution with (32 channels, 1 x 1 filters)
another convolution with (32 channels, 3 x3 filters)
merge (concatenate along the channel dimension)

Inception Module
The issue however is that the torch sizes as a result of the two convolutions are different.
(32 channels, 1 x 1 filters) -&gt; [1, 32, 30, 30]
(32 channels, 3 x3 filters) -&gt; [1, 32, 28, 28]
How can I concatenate the two branches?
Should I add padding? I tried ZeroPad2d. It’s not working.
For your reference:
class Inception(nn.Module):
def __init__(self, in_channel, ch1, ch3):
    super(Inception, self).__init__()
    self.branch1 = nn.Sequential(
        ConvBlock(in_channel, ch1, kernel_size = 1,stride=1, padding=0)
    )
    
    self.branch2 = nn.Sequential(
        ConvBlock(in_channel, ch3, kernel_size = 3,stride=1, padding=0)
    )
    
def forward(self, x):
    branch1 = self.branch1(x)
    branch2 = self.branch2(x)
    return torch.cat([branch1, branch2], 1) *(error here)*


You need to match your kernel size and padding.
For kernel_size=1 no padding is needed, but for kernel_size=3 you need padding to be 1:
self.branch2 = nn.Sequential(
        ConvBlock(in_channel, ch3, kernel_size=3,stride=1, padding=1)
    )

See this nice tutorial for more details.
