I get the equation:

image1232×274 13.9 KB

but it depends on Lin and Lout. I want them to be the same, but when defining my network, I don’t know what my input size will be. In my __init__, I have:
        l_in = 128
        padding1 = l_in - 1
        padding1 *= strides[0]
        padding1 += 1
        padding1 -= l_in
        padding1 += kernel_sizes[0] - 1
        padding1 /= 2
        print('padding1', padding1)
        padding1 = int(padding1)
        self.conv1 = torch.nn.Conv1d(
            in_channels=feature_dim,
            out_channels=feature_dim,
            kernel_size=kernel_sizes[0],
            stride=strides[0],
            padding=padding1)

This works well if I know what l_in is. But what if I don’t? For future sequences, I won’t have the length when defining the model.
Is it possible for me to define my padding in a way that’s independent from sequence length?