Reducing the channel numbers of a 5D tensor using convolutions

For reducing the number of feature maps in a 4D tensor, it is possible to use Conv2d while keeping the height and width of that tensor as the same as before. To be clearer, For example for the following 4D tensor [batch_size, feature_maps, height,weight] I use the following approach for reducing the number of feature maps but the height and size will be the same as before:

self.channel_reduction = nn.Conv2d(1024, 512, kernel_size=1, stride=1)

But I have the following 5D tensor [batch_size, feature_maps, num_frames, height, width] (e.g. [16, 1024, 16, 56, 56]) and I want to reduce the number of feature maps from 1024 to 512 while keeping the height and width size as the same as before (e.g. [16, 1024, 16, 56, 56]). How can I reduce the number of feature maps?

You could use nn.Conv3d for your 5D tensor.

Thanks, How I should select kernel_size, stride and padding?

You can use the same setup with a kernel size of 1 and no padding:

channel_reduction = nn.Conv3d(1024, 512, kernel_size=1, stride=1)
x = torch.randn(16, 1024, 16, 56, 56)
out = channel_reduction(x)
print(out.shape)
# torch.Size([16, 512, 16, 56, 56])