You are passing a 4-dimensional input, so you should use nn.Conv2d for it.
Also, if you don’t want to reduce the spatial size, you could use a 1x1 kernel or add padding, as currently your setup will yield an output of torch.Size([20, 2, 24, 24]).