# Get weight matrix for convolution network layer

I need to know the actual weight matrix that is obtained from the weights learnt by the convolution neural network. For a linear layer this is straight forward:

``````weights = linear_layer.weight
``````

This gives you the actual weight matrix with (also one can concat the bias if needed) which the intermediate input is multiplied with and so on and so forth. Unfortunately this is not as straight forward for the convultion layers where the weights are mostly shared and zero. Is there any function or method by which I can obtain a similar weight matrix for the convultion layers.

I need this as I want to perform some theoretical experiments involving the comutation of spectral norms for weight matrices for each layer and I can’t seem to find a straightforward way to do that for the convolution layers.

Getting the convolution weights should be as easy as your example.

Are you instead trying to find a matrix M that represents your convolution such that if you multiply your input by this matrix you’ll get the corresponding output? Something like this? neural network - 2-D convolution as a matrix-matrix multiplication - Stack Overflow