Expand size of tensor

Hi everyone,

I have feature maps with size: [1,100,20,30]. I want to scan over the feature maps with 10 filters with size of each filter: [1,1,5,5] to generate a new tensor with size: [1,100,20,30,1,10]. Last values of the size: 1 and 10 are the result values of the scanning process.

Could anyone give me an advice how to do that?
Thank you.

So you have an input with this format Batch x Channels x Width x Height and you want to apply a 5x5 kernel to generate an output of [BxCxWxHx1x10] or [Bx10*CxWxH]
can you not use Conv2d? here is my code for it

a = torch.rand(1,100,20,30)
cnv = torch.nn.Conv2d(in_channels=100, out_channels=100*10, kernel_size=5, stride=1, padding=2)
b = cnv(a).view(1,100,20,30,1,10)

The values of filter are set by myself, not a learnable kernel. For only one filter, I tried with:

a = torch.randn(1, 100, 20, 30) # Batch x Channels x Height x Width
kernel = kernel.view(1,1,5,5).repeat(100,1,1,1)
output = F.conv2d(a,kerkel.float(),group=100,padding=2)

and It can work. But I want to apply 10 filters to generate an output of [1, 100, 20, 30, 1, 10], it means that the output is a tensor of 1 batch of 20x30 of 1x10 vector of 100 channels.