%single neuron delta training with soft activation function % BATCH training format compact; clear all; ip=[1 2; 2 1], dp=[-1,1]', ww=[1 3 -3], c=2; k=0.5; figure(1); clf; hold on; xlabel('X input'); ylabel('Y input'); plot(ip(1,1),ip(1,2),'ro'); plot(ip(2,1),ip(2,2),'bx'); [np,ni]=size(ip); ip(:,ni+1)=ones(np,1) %augmenting input a=axis ; a=[0 4 0 4]; axis(a);j=0; for ite=1:125, if ite>1, plot(x,y,'g'); end; net=ip*ww'; op=tanh(0.5.*k.*net); fp=k.*(1-op.*op); er=dp-op; dw=(c*er.*fp)'*ip; ww=ww+dw; x(1)=-1; y(1)=-(ww(1)*x(1)+ww(3))./ww(2); x(2)=4; y(2)=-(ww(1)*x(2)+ww(3))./ww(2); plot(x,y,'r'); % pause; ter=er'*er, tter(ite)=ter; if ter <0.001, break; end; end; hold off; ite figure(2); clf; semilogy(tter); xlabel('iterations'); ylabel('error');