app1_neu.m
来自「其中提到遺傳學的程式碼與應用提供給次淚相向的研究者參考下載」· M 代码 · 共 38 行
M
38 行
% Find a NN controller for problem in Appendix 1
% app1_neu.m
% PenChen Chou, Aug. 9, 2001
% Input pattern
P=[ -1 -1; -1 0; -1 1;
0 -1; 0 0; 0 1
1 -1; 1 0; 1 1];
P=P';
% Target
T=[-1 -1 0 -1 0 1 0 1 1];
% New Feedforward NN
net = newff([-1 1;-1 1],[2 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.1)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?