Monday, 11 February 2013
Function Approximation with AI methodologies
5/2/13
I found out how to get the NN to display the funtion it has created. you use the sim command to simulate the results example:
x=0:0.05:2;
y=humps(x);
P=x; T=y;
plot(P,T,'x')
xlabel('time'); ylabel('output'); title('Original Function');
net = fitnet(3, 'trainlm'); %fitnet is feedforward network 'n' neurons, and training function
%default settings; 1000 iterations
net = train(net,P,T);
view(net); %diagram of network
y = net(x);
a= sim(net,P);
% Plot result and compare
plot(P,a-T,P,a, P,T); grid;
legend('error', 'NN function', 'Original');
If you inrease the number of neurons you can see the NN fuction becoming closer to the orignal, also the error line is closer to zero.
humps(x) is a demo function which is equivalent to :
y = 1 ./ ((x-.3).^2 + .01) + 1 ./ ((x-.9).^2 + .04) - 6;
Alterantively you can use the data set
[x,y] = simplefit_dataset;(no need for the x=0:0.05:2 with this)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment