sim–对训练好的的网络进行仿真
clear all;
net=newp([-2,2;-2,2],1);
P=[0,0,1,1;0,1,0,1];
T=[0,0,1,1];
net=train(net,P,T);
Y=sim(net,P);
Y=net(P)
hardlim、hardlims–感知器传输函数
clear all;
figure;
subplot(2,1,1);
n=-5:0.01:5;
plot(n,hardlim(n),'LineWidth',2);
title('hardlim');
subplot(2,1,2);
plot(n,hardlims(n),'r','LineWidth',2);
title('hardlims');
clear all;
net=newp([-1,2;-2,2],1);
P={[0;0] [0;1] [1;0] [1;1]};
T={0,0,1,1};
[net,y,ee,pf]=adapt(net,P,T);
ma=mae(ee)
ite=0;
while ma>=0.15
[net,y,ee,pf]=adapt(net,P,T,pf);
ma=mae(ee)
newT=sim(net,P)
ite=ite+1;
if ite>=10
break
end
end
mae–平均绝对误差性能函数
clear all;
net=newp([-10 10],1);
p=[-10,-5,0,5,10];
t=[0,0,1,1,1];
y=sim(net,p);
e=t-y;
perf=mae(e);
sum(abs(e))/length(e);
net=train(net,p,t);
y=sim(net,p);
e=t-y;
perf=mae(e)