MATLAB: How to see the weight and biases variables in neural networks, please show me on simple example code

neural networksweights and biases

How do I see the weight and biases variables in neural networks, please show me on simple example code?

Best Answer

You can find some code examples using the Neural Network Toolbox here.
Copying from there, one example deals with classifying the sex of crabs.
[x,t] = crab_dataset; %load the dataset
net = patternnet(10); %create the network
[net,tr] = train(net,x,t); %train the network
Now, you can find the weights and biases by looking at net .
w1 = net.IW{1} %the input-to-hidden layer weights
w2 = net.LW{2} %the hidden-to-output layer weights
b1 = net.b{1} %the input-to-hidden layer bias
b2 = net.b{2} %the hidden-to-output layer bias
Hope this helps.