How neural network output is calculated ?
9 views (last 30 days)
Show older comments
For example
function Example_3()
net = feedforwardnet(1);
p = [[2;2] [1;-2] [-2;2] [-1;1]]
t = [1 2 1 2]
net.layers{1}.transferFcn = 'logsig';
net.layers{2}.transferFcn = 'logsig';
net = train(net,p,t);
wb = formwb(net,net.b,net.iw,net.lw);
[b,iw,lw] = separatewb(net,wb);
end
If
iw are -1.60579942154570 and 5.53933429980683
lw is -24.9335783159999
biases are -1.16445538542225 for the hidden neuron
and 7.83599936414935 for the output neuron
I was able able to calculate the correct values when using a perception but not with neural networks for some reason
I calculate the output using logsig(logsig((IW1*Input1)+(IW2*Input2)+bias1)*LW1+bias2)
If I input -1 and 1, how is the output calculated as 1.9994?
Shouldn't the output be between 0 and 1 because of the logsig ?
1 Comment
Greg Heath
on 6 Feb 2018
When you choose examples, it is worthwhile to 1st consider continuous functions like ones in the help and doc documentation AND include plots of the inputs, targets and targets vs inputs.
Accepted Answer
Greg Heath
on 6 Feb 2018
When you calculate the output of a net you have to take into account that values in the calculations are scaled, by default,
Hope this helps
Thank you for formally accepting my answer
Greg
1 Comment
More Answers (1)
Greg Heath
on 12 Feb 2018
If your outputs are constrained to [ 0, 1 ] use SOFTMAX
If your outputs are constrained to [ -1, 1 ] use TANH
Otherwise use LINEAR
Hope this helps.
Thank you or formally accepting my answer
Greg
0 Comments
See Also
Categories
Find more on Define Shallow Neural Network Architectures 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!