How can we get values of weights from any layer of the model
See original GitHub issueI want to get the weight & bias values of any layer of choice, how can I access the same?
I could get the Kernel Shape, stride, pad, inputs, output for a particular layer. But how do I get the parameter values of a layer from model.onnx file. I am new to Protobuf.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
How to get the weights of Keras model? - AI Pool
Keras has implemented some functions for getting or setting weights for every layer. layer.get_weights(): returns the weights of the layer ...
Read more >How do I get weights and biases from my model?
In any case, take into account that there are layers which weights aren't saved (as they don't have weights), so if asking for...
Read more >Get weights and biases of a particular layer of NN in MXNet
We can access weights and bias with the .data() method. We can access the weight or bias of a specific layer by using...
Read more >Model Summary - Getting Layers With Weights - YouTube
Model Summary | Plotting Model | Getting Layers With Weights | Saving Models | Loading Weight ************************************This video ...
Read more >Access all weights of a model - PyTorch Forums
Please note that, I know that weights can be accessed layer-wise ( my_mlp.layers[0].weight, my_mlp.layers[2].weight). Thanks with best regards.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @holoLens8, here is an example (I’m using mobilenetv2). You can load the model in Netron to explore visually and find the nodes you want.
You will be able to see the names of the node inputs. Here I have selected the first
Convnode, and the weight input W is namedmobilenetv20_features_conv0_weight. This code snippet will give you the constant (weight matrix, bias, etc.) as a numpy array:You can understand how to interpret the numpy array by looking at the operator documentation – for example the
Convoperator says that the weight tensor is of shape:For example, in python: