# How are the weights and the bias in matlab nueral network system arranged in context with using getwb(net)?

Say I have 2 input neurons, 3 hidden neurons and 1 output neuron. The total number of weights that are used are understandably 3*(2+1)+1(3+1)=13. Here there the multiplicative the number of weights is 9 and the the number of bias is 4. In what manner are the weights arranged (in a column) while obtaining them using getwb(net) on MATLAB. Is it that all the weights including hidden (32=6, here) and the output(31=3) are arranged first and then the bias (3+1) are arranged or there is some other order?

Thank you in advance for your response.

## 1 Answer

The documentation here doesn't explain it unfortunately, but using the example given there, we can see that it's being

[x,t] = simplefit_dataset;
net = feedforwardnet(3);
net = train(net,x,t);
wb = getwb(net);

mean([net.b{1}; net.IW{1}; net.b{2}; net.LW{2,1}'] == wb)


which yields 1 as output (i.e. every element is correct). The IW is the weights between the input and the first hidden layer, and LW is weights between each consecutive layer. And, b field is just biases for every layer.

So, the first block of wb (the vectorized weights) is all the weights between the input and the first hidden layer, starting with biases, and the second block is the weights between the hidden layer and the output layer, i.e. L1 and L2, which is why we access the cell {2, 1} in LW, starting with the bias again.