Linear combination of feature maps

Hi, I want do to some linear combination of feature maps.

Let’s say, the feature maps f now have size of: batchchannelM*N
I want a linear layer: fc = nn.Linear(channel, 1)

and after the operation: y = fc(f)
the output y should have size: batchMN, where fc has weights to update.

How do I do this in pytorch?

I just realize that this operation is a convolution of kernel size 1x1.