Bixqu:

How can this be done?


You could use the functional API via F.linear and define the weight and bias depending on your input shape.
However, this would create a new parameter for each input shape and I’m not sure, if that’s what you want.
Usually you would add e.g. an adaptive pooling layer to make sure the incoming activation has always a defined shape.