I have a trained model. I want to chenge bias of some convolutions in the model for better inference performance. for example, the shape of kernel is (C_out, C_in, 3, 3) and the shape of bias is (C_out, ). I want to set new value to bias. the shape of new bias is (C_out, C_in, 3, 3) and it can set different bias for every point in kernel. how can i achieve this?
Do you mean you want a bias of shape e.g., (k, k, C_out), or of (output_y, output_x, C_out)? For the former, note that it should basically be equivalent to the existing case as the values would simply be added up. For the latter, you would need to need to disable the bias in the convolution and create a new layer for the bias as it would have different semantics than native Conv2d.