//// Letter recognition with threshold perceptron clear; clf; nIn=12*13; nOut=26; // number of input and output channels wOut=rand(nOut,nIn)-0.5; //random initial weight matrix // training vectors pattern1=read('pattern1',26*12,13); rIn=matrix(pattern1', nIn, 26); rDes=diag(ones(1,26)); // matrix of desired outputs // Updating and training network for training_step=1:20; // test all pattern rOut=(wOut*rIn)>0; // threshold activation function dist=sum(sum(abs(rDes-rOut)))/26; errorNet(training_step)=dist; // training with delta rule wOut=wOut+0.1*(rDes-rOut)*rIn'; end plot(0:19,errorNet) xlabel('Training step') ylabel('Average number of wrong bits')