?? eval_nn.m
字號:
% eval_nn.m
% Read FIS
nn_flc=readfis('nn1_flc');
disp('==>Load nn1_flc FIS complete!');
% Input patterns
P=[0.8 0.8; 0.8 0; 0.8 -0.8; 0.3 0.3;
0.3 -0.3; 0 0.8; 0 0; 0 -0.8;
-0.3 0.3; -0.3 -0.3; -0.8 0.8; -0.8 0;
-0.8 -0.8];
IN_patterns=P'
% Output targets
Targets=[1 0.55 0 0.35 0 0.55 0 -0.55 0 -0.35 0 -0.55 -1]
% Evaluate FIS
Fuzzy_out=[evalfis(IN_patterns,nn_flc)]'
% Training a FF NN
net = newff([-1 1;-1 1],[4 1],{'tansig' 'purelin'});
net.trainParam.epochs = 1500;
net = train(net,IN_patterns,Targets);
% Display results
Targets=[1 0.55 0 0.35 0 0.55 0 -0.55 0 -0.35 0 -0.55 -1]
Neural_out = sim(net,IN_patterns)
% Plot NN training results
sample=1:13;
figure(2);plot(sample,Targets,sample,Neural_out,'--')
title('NN training results plots(Solid=Targets,dash=NN out)');
xlabel('(Use of eval_nn.m) Samples');
ylabel('Outputs')
% Plot 3-d
gop=input('Take several minutes to plot 3D graph,OK<CR>?(0=NO plot):');
if isempty(gop)
x=-1:0.02:1; y=x;
[X, Y]=meshgrid(x,y);
[M, N]=size(X);
for I=1:M
for J=1:N
F_out(I,J)=evalfis([X(I,J) Y(I,J)],nn_flc);
N_out(I,J)=sim(net,[X(I,J); Y(I,J)]);
end
end
figure(3);mesh(X,Y,F_out)
figure(4);mesh(X,Y,N_out)
end
disp('Done eval_nn<<<');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -