testtu.m

来自「BP神经网络」· M 代码 · 共 48 行

M
48
字号
%test the multiple images
clear
clc
wkj=load('wkj2(2).dat');
wji=load('wji2(2).dat');
right=0;
righttu=[];
rightv=[0 0];
wrong=0;
test=0;
id=[];
  for j=0:9
    str1=int2str(j);
    for k=9:10
        str2=int2str(k);
           testfnamestr=strcat(str1,'-',str2,'.bmp');
          testfname=imread(testfnamestr);
          testfname2bw=im2bw(testfname);
          testinvector=getfeature(testfname2bw);
          netj=wji*testinvector;                    %netj is 14*1
          yj=f(netj);                    %yj is 14*1
          netk=wkj*yj;                   %netk is 10*1
          z=f(netk);                     %z is 1*10
         ceshitu=find(z==max(z));
         ceshitu=int2str(ceshitu);
           if ceshitu=='10'
           ceshitu='0';
          end
          if ceshitu==str1
              rightv=[j,k];
              righttu=[righttu;rightv];
             right=right+1;
             test=test+1;
             
          else 
             wrong=wrong+1;

          test=test+1;
      end
                
    end
end
test
right
wrong

     

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?