Single convolution

Hi all,

If I were to use a Conv2d with a stride of 1, a kernel size of 1, no padding and no bias. This would be equivalent to multiplying a matrix by another matrix right?

        self.matrix_mul = 
            nn.Conv2d(
                in_channels=3,
                out_channels=3,
                kernel_size=1,
                stride=1,
                padding=0,
                bias=False)

So essentially if I were to train a single layer on a dataset where:
Input: square image
Target: same square image
The single layer would learn the identity matrix right?
(Ps. Iā€™m a bit rusty on my matrix math.)

Thanks.

The short answer is yes.

A Conv2d with kernel size 1 and no padding will apply the same transformation independently to every pixel in the image.

Each channel of each output pixel will simply be a linear combination of the input channels of the corresponding pixel.

1 Like