Can convolutions in pytorch be 3x1 rectangular or just square

I am new to pytorch but not new to image processing. I am so old that when I started with image processing we used to build our own convolvers from discrete multipliers and accumulators (a 3x3 conv took 9 discrete multipliers).

Of course, in discrete code like C or python one can do a convolutional filter in any size or or shape. But I am new to pytorch and I see convolution functions but so far have not seen a way to adjust the “shape” of the convolution filter to be anything but square as opposed to rectangular.

Thank You
Tom

Hy Tom,
Yes you can use rectangular convolution filter.

# consider input (3,128,128)
torch.nn.Conv2d(3,64,(1,3),stride=2,groups=1)
torch.nn.Conv2d(64,128,(3,1),stride=2,groups=1)
# Then output after these convolutions will be (128,31,32)
1 Like