Strange results with Matlab Neural Network Toolbox
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Greg Heath
el 24 de Abr. de 2012
0 votos
Please do not email followups. Stay within Answers.
If the following does not help, reply here, not via email.
> 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
1 comentario
IEfremov
el 26 de Abr. de 2012
Categorías
Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!