Strange results with Matlab Neural Network Toolbox

Created and trained the network with NNToolbox, exported the weights and biases. The network works perfect, using sim(net) or just net(x). But when I try to reproduce the result with pen and paper, using the same weights and biases, the output is completely different. For testing I created a single layer net with PURELIN activation function. All weights and biases set to zero. According to all ANN books and wikipedias the result would be zero for all inputs, but Matlab says it's 0.5! If we set the weights to 1 and the biases to 0 (with PURELIN function the output must be the arithmetic sum of inputs), the result is even stranger: for [0;0] input it's -0.0611, for [1;1] it's 1.0605 and for [2;2] the output 2.1821. I am confused: I always believed Matlab and took its results "as is", but I can't explain that.

 Accepted Answer

By default, the feedforward nets transform the data using MAPMINMAX.
Therefore you have to either disable this default or use MAPMINMAX in your calculation.
See the documentation. For example,
help NEWFF
doc NEWFF
Similarly for
FEEDFORWARDNET, FITNET AND PATTERNNET
Hope this Helps.
Greg

More Answers (1)

Please do not email followups. Stay within Answers.
If the following does not help, reply here, not via email.
% On Mar 31, 9:09 pm, "Siva " <mailto:sivaath...@gmail.com sivaath...@gmail.com> wrote:
> I am trying to determine the final equation for the trained network.-----SNIP
close all, clear all, clc
help feedforwardnet
[ x, t ] = simplefit_dataset;
[ I N ] = size(x)
[ O N ] = size(t)
whos
figure
hold on
plot(x,t,'o','LineWidth',2)
drawnow
H = 10
net = feedforwardnet(H);
net = train(net,x,t);
view(net)
y = net(x);
plot(x,y,'r','LineWidth',2)
drawnow
IW = net.IW{1,1}
LW = net.LW{2,1}
b1 = net.b{1}
b2 = net.b{2}
xmin = min(x)
xmax=max(x)
xn = -1+ 2*(x-xmin)/(xmax-xmin) ;
h =tansig(IW*xn+b1*ones(1,N));
yn = LW*h+b2;
tmin = min(t)
tmax = max(t)
yhat = tmin +(tmax-tmin)*(yn +1)/2;
plot(x,yhat,'g','LineWidth',2')
mse(y-yhat)
Hope this helps.
Greg

Categories

Find more on Deep Learning Toolbox 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!