# Understanding Convolution with an Even Sized Filter

If I have an even sized convolutional filter, say 2 by 2, f_{i,j} for 1<= i <=2, 1<= j < = 2

Then if I apply it to a window centered at (x,y) (assuming appropriate padding),
then will it apply something like
f_{1,1} (x,y) + f_{1,2} (x+1, y) + f_{2, 1}(x, y+1) + f_{2,2}(x+1, y+1) in Pytorch?
I’m not sure what the formula would be for even sized filters basically.
Thanks.

I’m not sure what your notation means exactly, but you could use a simple example as given here:

``````weight = torch.ones(1, 1, 2, 2)
x = torch.arange(4*4).view(1, 1, 4, 4).float()
print(weight)
> tensor([[[[1., 1.],
[1., 1.]]]])

print(x)
> tensor([[[[ 0.,  1.,  2.,  3.],
[ 4.,  5.,  6.,  7.],
[ 8.,  9., 10., 11.],
[12., 13., 14., 15.]]]])

out = F.conv2d(x, weight, stride=1, padding=0)
print(out)
> tensor([[[[10., 14., 18.],
[26., 30., 34.],
[42., 46., 50.]]]])

out = F.conv2d(x, weight, stride=1, padding=1)
print(out)
> tensor([[[[ 0.,  1.,  3.,  5.,  3.],
[ 4., 10., 14., 18., 10.],
[12., 26., 30., 34., 18.],
[20., 42., 46., 50., 26.],
[12., 25., 27., 29., 15.]]]])
``````

As you can see, the kernel will use windows of `2x2` to create its output.

Let me know, if this example makes the output clear or if you would need more information.