net1=newp([-1 1;-1 1],1); net11=newp([-1 1;-1 1],1); p1=[1 -1 1 -1;1 -1 -1 1]; p2=[-1 1 1 -1;-1 1 -1 1]; net1.inputweights{1}.initFcn=‘rands‘; net11.inputweights{1}.initFcn=‘rands‘; net1.biases{1}.initFcn=‘rands‘; net11.biases{1}.initFcn=‘rands‘; index=0; while index==0 net1=init(net1); iw11=net1.IW{1} b11=net1.b{1} [t11,pr1]=sim(net1,p1); net11=init(net11); iw12=net11.IW{1} b12=net11.b{1} [t12,pr2]=sim(net11,p2); net2=newp([0 1;0 1],1); net2.trainParam.epochs=10; net2.trainParam.show=1; p21=ones(size(t11)); p21=p21.*t11; p22=ones(size(t12)); p22=p22.*t12; p3=[p21;p22]; t2=[1 1 0 0]; [net2,tr2]=train(net2,p3,t2); epoch2=tr2.epoch; perf2=tr2.perf; iw2=net2.IW{1}; b2=net2.b{1}; t3=sim(net2,p3); save Percept02 net1 net2 if t3==t2 index=1; end end
时间: 2024-10-11 12:48:42