How do I get the weights and/or biases for my network in a clean matrix or table.
59 次查看(过去 30 天)
显示 更早的评论
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
回答(1 个)
Lokesh
2023-10-9
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!