Is there a rule of thumb for determining the size of a convolutional filter given the shape of the input? Specifically, if you want to do a 1D convolution over an even-length vector, does the kernel need to be a divisor of the vector length? Does the kernel need to be even? I understand that when using an odd-length kernel, you align the center element with the stride position on the input vector, but with even-length kernels there is no center position. For example, if I have a vector [a,b,c,d]
and a kernel [0,1]
, should the kernel start by aligning 1
with a
or should 0
align with a
?
Also is there any theory on why and how much padding and stride you should use when convolving and trade-offs between these two parameters?
Solved – How to handle even and odd convolutional filter sizes and images
conv-neural-networkconvolutionneural networks
Related Question
- Solved – 2D convolution with depth
- Solved – Convolutional neural networks – What is done first? Padding or convolving
- Solved – Problem figuring out the inputs to a fully connected layer from convolutional layer in a CNN
- Solved – Padding and stride in backpropagation of a conv net
- Solved – Convolutional network – how to choose output channels number, stride and padding
- Solved – Does padding ensure that the sizes of input and output of a CNN match
- Why convolution output size is different using Toeplitz matrix
Best Answer
It's usual to use stride 1 and pad the input layers such that the output layers so that they are the same size as the input layers. Using stride lengths of 1 separates the processes of feature extraction (the job of the convolutional layers) and making the model invariant to spatial translation (the job of the pooling layers). Padding the input layers ensures that the model doesn't slowly lose information about edge elements.