How can I scale up a Conv1D?

If I have a Conv1d layers:

        self.conv1 = torch.nn.Conv1d(
            in_channels=feature_dim,
            out_channels=feature_dim,
            kernel_size=kernel_sizes[0],
            stride=1
        )
            # padding=kernel_sizes[0] // 2)

        self.conv2 = torch.nn.Conv1d(
            in_channels=feature_dim,
            out_channels=feature_dim,
            kernel_size=kernel_sizes[1],
            stride=1
        )
            # padding=kernel_sizes[1] // 2)

        self.conv3 = torch.nn.Conv1d(
            in_channels=feature_dim,
            out_channels=feature_dim,
            kernel_size=kernel_sizes[2],
            stride=1
        )
            # padding=kernel_sizes[2] // 2)

        self.conv4 = torch.nn.Conv1d(
            in_channels=feature_dim,
            out_channels=feature_dim,
            kernel_size=kernel_sizes[3],
            stride=1,
            padding=2)

My sizes look like:

inp torch.Size([8, 161, 196])
out1 torch.Size([8, 161, 186])
out2 torch.Size([8, 161, 178])
out3 torch.Size([8, 161, 172])
out4 torch.Size([8, 161, 188])

But I want conv4 to increase the from 172 back to 196. I assume I can control that with padding, but I’m not sure how.

It’s hard to tell which padding value you need, as the kernel sizes are not defined in the code snippet, however you could try increasing the padding until the temporal size matches your expectation.

I would also recommend to check, if adding padding in the intermediate layers wouldn’t be the better option to avoid the reduction in the temp. dimension in the first place instead of filling the result with zeros.