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8; 0.8 1;
1 -1; 1 -0.8; 1 -0.6; 1 -0.4; 1 -0.2; 1 0; 1 0.2; 1 0.4; 1 0.6; 1 0.8; 1 1];
P=P';
% Target
T1=[-1 -1 -1 -1 -1 -1 -0.8 -0.6 -0.4 -0.2 0];
T2=[-1 -1 -1 -1 -1 -0.8 -0.6 -0.4 -0.2 0 0.2];
T3=[-1 -1 -1 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4];
T4=[-1 -1 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6];
T5=[-1 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8];
T6=[-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1];
T7=[-0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 1];
T8=[-0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 1 1];
T9=[-0.4 -0.2 0 0.2 0.4 0.6 0.8 1 1 1 1];
T10=[-0.2 0 0.2 0.4 0.6 0.8 1 1 1 1 1];
T11=[0 0.2 0.4 0.6 0.8 1 1 1 1 1 1];
T=[T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11];
% New Feedforward NN
net = newff([-2 2;-2 2],[7 1],{'tansig' 'purelin'},'trainlm');
net.trainParam.epochs = 1500;
net.trainParam.goal = 1e-12;
% Training
net = train(net,P,T);
disp('Press <CR> to continue');pause
% Get the Neural output
Y = sim(net,P);
% Reprint the Target
% Display weights and bias
W10=net.IW{1,1}
B10=net.b{1}
W20=net.LW{2,1}
B10=net.b{2}
% Plot the target and neural outputs
sample=1:length(T);
figure(2);plot(sample,T,'o',sample,T,sample,Y)
title('Desired and Neural output plots')
xlabel('Sample points');
gensim(net,0.01)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -