How to calculate the NN outputs manually?
이전 댓글 표시
Can anyway help me explaining manual calculation for testing outputs with trained weights and bias? Seems it does not give the correct answers when I directly substitute my inputs to the equations (Transfer function equations). Answers are different than what I get from MATLAB NN toolbox. How is it possible to get a large number as an output (eg: 100) when the output node has a transfer function, because as an example output from the "logistic" transfer function is always between 0 and 1?
채택된 답변
추가 답변 (2개)
Greg Heath
2016년 5월 8일
By default,
1. The hidden node transfer function is TANSIG (TANH)
2. The output node transfer function is PURELIN (LINEAR)
3. Inputs and targets will be AUTOMATICALLY transformed
to [-1,1] for calculating purposes
4. The outputs will be AUTOMATICALLY transformed from
[ -1,1] to the original target scale.
Hope this helps.
Greg
댓글 수: 2
Darshana Abeyrathna
2016년 5월 8일
Amir Qolami
2020년 4월 12일
For apply mapminmax to inputs:
xoffset = net.Inputs{1}.processSettings{1}.xoffset; gain = net.Inputs{1}.processSettings{1}.gain; ymin = net.Inputs{1}.processSettings{1}.ymin; In0 = bsxfun(@plus,bsxfun(@times,bsxfun(@minus,inputs,xoffset),gain),ymin);
And for apply reverse mapminmax to outputs:
gain = net.outputs{end}.processSettings{:}.gain; ymin = net.outputs{end}.processSettings{:}.ymin; xoffset = net.outputs{end}.processSettings{:}.xoffset; output = bsxfun(@plus,bsxfun(@rdivide,bsxfun(@minus,outputs,ymin),gain),xoffset);
hassan khatir
2023년 7월 19일
0 개 추천
use this function:
function y2=sim2(net,x)
xoffset=net.inputs{1}.processSettings{1}.xoffset;
gain=net.inputs{1}.processSettings{1}.gain;
ymin=net.inputs{1}.processSettings{1}.ymin;
w1 = net.IW{1}; % (10x6)
w2 = net.LW{2}; % (2x10)
b1 = net.b{1}; % (10x1)
b2 = net.b{2};
% Input 1
y1 = (x-xoffset).*gain+ymin;
% Layer 1
a1 = 2 ./ (1 + exp(-2*(repmat(b1,1,size(x,2)) + w1*y1))) - 1;
% output
outputs=repmat(b2,1,size(x,2)) + w2*a1;
gain = net.outputs{2}.processSettings{:}.gain;
ymin = net.outputs{2}.processSettings{:}.ymin;
xoffset = net.outputs{2}.processSettings{:}.xoffset;
y2 = (outputs-ymin)./gain + xoffset;
end
카테고리
도움말 센터 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!