Why is predicting the output of a trained neural network by using "net/sim" different than manually calculating the output using the network weights, biases and transfer functions?
%%create random data rng(1); xdata = rand(5,100); ydata = rand(1,100); %%fit a forward network nlayersize = 10; net = feedforwardnet(nlayersize); net.trainParam.showWindow = false; net = train(net,xdata,ydata); net.layers{1}.transferFcn %%calculate the model output at a new point xNew = rand(5,1); y1 = net(xNew); % can use sim as well %%manually calculate model output IW = net.IW{1}; LW = net.LW{2,1}; b = net.b; y2 = IW*xNew+b{1}; y2 = tansig(y2); y2 = LW*y2+b{2}; dy = y1-y2
xNew = rand(5,1); y1 = net(xNew); xNew = mapminmax('apply', xNew , net.inputs{1}.processSettings{1}); % apply input pre-processing IW = net.IW{1}; LW = net.LW{2, 1}; b = net.b; y2 = IW*xNew+b{1}; y2 = tansig(y2); y2 = LW*y2+b{2}; y2 = mapminmax('reverse', y2, net.outputs{2}.processSettings{1}); % reverse the output pre-processing dy = y1 - y2
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.