how to use weights and thresholds from Neural Network toolbox
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Establish a very simple feed forward network to approximate sin wave:
x=[0:0.1:10];
y=sin(x);
net=newff(x,y,30); %30 neurons
net=train(net,x,y); %train
y=sim(net,x);
plot(x,sin(x),x,y);
The result is good. However, if I take the weight and threshold matrix from this network:
w1=net.IW{1,1};
w2=net.LW{2,1};
b1=net.b{1};
b2=net.b{2};
and use a loop to simulate it:
xx=[0:0.5:5];
for i=1:size(x,2)
Y(i)=w2*tansig(w1*xx(i)+b1)+b2;
end
plot(xx,sin(xx),xx,Y);
the result is totally different. Is there any problem?
0 comentarios
Respuestas (3)
Andres Zarate de Landa
el 26 de Abr. de 2011
I figured out the problem! The thing here is that newff by default normalices the inputs and outputs using the mapminmax function. You can see that by typing net.inputs{1}.processFcns 'fixunknowns' 'removeconstantrows' 'mapminmax'
net.outputs{2}.processFcns 'removeconstantrows' 'mapminmax'
So, if you don't want normalized inputs and outputs as in my case just remove the mapminmax function: net.inputs{1}.processFcns = {'fixunknowns', 'removeconstantrows'}; net.outputs{2}.processFcns = {'removeconstantrows'};
And that's all! the weights and biases won't be normalized and you can use these parameters in your own ANN using any software. I hope this helps
0 comentarios
Mark Hudson Beale
el 19 de Abr. de 2011
You need to first preprocess inputs, then post process outputs as follows:
xx = [0:0.5:5]
for i=1:length(net.inputs{1}.processFcns)
xx = feval(net.inputs{1}.processFcns{i},...
'apply',xx,net.inputs{1}.processSettings{i});
end
for i=1:size(x,2)
Y(i)=w2*tansig(w1*xx(i)+b1)+b2;
end
for i=1:length(net.outputs{2}.processFcns)
Y = feval(net.outputs{2}.processFcns{i},...
'reverse',Y,net.outputs{2}.processSettings{i});
end
You can replace the FEVAL calls with direct calls to the functions in "net.inputs{1}.processFcns" and "net.outputs{2}.processFcns" if you like.
0 comentarios
Andres Zarate de Landa
el 25 de Abr. de 2011
I have the exact same problem, I need the Weights and biases to simulate the ANN using equations on ADS. The function aproximation results using the "sim" function are ok, however when I try to simulate it it doesn't work at all. I don't know what's wrong can anybody help please?
Thanx
0 comentarios
Ver también
Categorías
Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!