How do I get the weights and/or biases for my network in a clean matrix or table.
23 views (last 30 days)
Show older comments
Hello friends I'm a beginner and only use NNs for my research in economics.
I'm aware of the "getwb(net)" function but I'd prefer to have the weights and biases for each neuron in an understable and presentable table. (if it is possible)
Currently I'm making seperate variables for weights and biases of wach neuron from the diagram i generated using "gensim(net)" but for an extensive reseach this can get a bit exhausting and I feel there might be an easier way.
thank in advance
Answers (1)
Lokesh
on 9 Oct 2023
Hi Pashton,
I understand that you want to extract weights and biases of neural network in a readable format.
To extract the input weights and layer weights of a neural network in a readable format, you can use the “net.IW” and “net.LW” properties, respectively. Similarly, you can use “net.b” to extract the biases.
Here is an example code snippet that demonstrates how to extract weights and biases:
% Extract input weights and layer weights
w = [net.IW{1}, net.LW(2:size(net.LW, 1)+1:end)];
% w{1} contains weights associated between the input layer and the first hidden layer
% w{m}(n,:) contains weights associated with the 'n'th neuron of hidden layer m
% Extract biases
b = net.b';
% b{m} contains biases associated with hidden layer m
Please refer to the following MATLAB documentation link to know more about Weight and Bias Value Properties:
I hope this helps you in resolving the issue.
Best Regards,
Lokesh
0 Comments
See Also
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!