Change number of channel

Hi, I want to change number of channels from torch.Size([1, 3, 128, 128]) to torch.Size([1, 1, 128, 128])…How to do that?

I guess there are several ways to do that but Separable Convolution is a popular option.

a = torch.rand(1, 3, 128, 128)
layer = torch.nn.Conv2d(in_channels=3, out_channels=1, kernel_size=1)
out = layer(a)