这个网络只有不到800行可以实现多层多分类任务,3层网络测试mnist数据集10分类,最高可以达到98.48%。这个程序包含13个子程序,有6个变量和8个本地路径。只需确保电脑已经安装java环境,并且8个本地的路径都正确程序就可以运行。

代码

使用说明

一.13个子程序

二.6个变量

三.8个路径

四.标定数据

五.极限性能测试

package cpa;import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.Random;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;public class d3n {static double ret=0.1; //学习率      ***(3)  减小static double weix=100;//权重          ***(4)  减小  static double p;/************************************************************/static int cy=1; //层数 ***(7)//1*3-0=3     2*3-1=5   3*3-2=7  4*3-3=9   cy*3-(cy-1) //static int[] tra= {0,1,2,3,4,5,6,7,8,9};  //训练集//static int[] fen= {0,1,2,3,4,5,6,7,8,9};  //测试集/*static int shuru=28*28;static int yc=300;static int shuchu=490;*/static int[] tra= {0,2};  //训练集static int[] fen= {0,2};  //测试集***(2)static int shuru=9*9;static int yc=30;       //***(5)  减小static int shuchu=49;  /**********************************************************/ static double train[][][]=new double[tra.length][5000][shuru];    static double test[][][];/***********************************************************/static FileWriter fileWriter5 ; static int [][]nr;static int [][]mr;static int [][]kr;static double[] xr;static double[] y;static double w1r [][][];static double w2r [][][];static double wf1r [][][];  static double wf2r [][][];  static double [][]fr ;static double [][]ffr;static double [][]dr;static double [][]ddr;static int z=tra.length;public static  void ini(  ) throws IOException, ParseException { w1r =new double[cy][1][1];w2r =new double[cy][1][1];wf1r =new double[cy][1][1];wf2r =new double[cy][1][1];fr =new double[cy][1];ffr=new double[cy][1];dr =new double[cy][1];ddr=new double[cy][1];nr=new int[cy][1];mr=new int[cy][1];kr=new int[cy][1];nr[0][0]=shuru;mr[0][0]=yc;kr[0][0]=shuchu;   for(int a=1 ;a<cy ;a++){nr[a][0]=shuchu;mr[a][0]=yc;kr[a][0]=shuchu;   }kr[cy-1][0]=tra.length;for(int a=0 ;a<cy ;a++){w1r[a] =new double[nr[a][0]][mr[a][0]];w2r[a] =new double[mr[a][0]][kr[a][0]];wf1r[a] =new double[nr[a][0]][mr[a][0]];wf2r[a] =new double[mr[a][0]][kr[a][0]];fr[a] =new double[mr[a][0]];ffr[a]=new double[kr[a][0]];dr[a] =new double[mr[a][0]];ddr[a]=new double[kr[a][0]];}xr =new double[nr[0][0]];y=new double[kr[cy-1][0]];   }public static  void ini1(  ) throws IOException, ParseException { double []bcon=new double[shuru];for( int at=1 ;at<5000;at++)  {for(int v=0;v<kr[cy-1][0];v++)   {   String str="d:/工业/10/"+tra[v]+"/"+at+".jpg";   //***A    bcon=pix(str,shuru);train[v][at]=bcon;                    }}/***************************************************************/test=new double[fen.length][1][shuru];for(int a=0 ;a<fen.length ;a++){String sf="b"+fen[a];String path="d:/工业/10/"+sf+"/";   //***BFile file=new File(path);File[] tempList = file.listFiles();double []con2=new double[shuru];test[a]=new double[tempList.length][shuru];System.out.println( test.length+" "+test[a].length+"   *  " );for (int i = 0; i < tempList.length; i++) {if (tempList[i].isFile()) {String[] b=Pattern.compile(sf).split(tempList[i].toString());/*****************************************************************/String[] b1=Pattern.compile("\\.").split(b[1]);b1[0]=b1[0].substring(1, b1[0].length()); String name=tempList[i].toString();int id=Integer.parseInt(b1[0]);con2=pix(name,shuru);test[a][i]=con2;}}}     }  public static  double[]  pix( String a,int shuru ) throws IOException, ParseException {String openf=a;BufferedImage image=ImageIO.read(new File(openf)); int k=(int) Math.pow(shuru, 0.5);double [] x=new double[k*k];double[][] pixt=new double[k][k];int count=-1;for(int i=0;i<k;i++){ for(int j=0;j<k;j++){count++;int[] rgb = new int [3];int t=(int)(28/k);int pixel = image.getRGB(i*t , j*t);rgb[0] = (pixel & 0xff0000) >> 16;rgb[1] = (pixel & 0xff00) >> 8;rgb[2] = (pixel & 0xff);pixt[i][j]=0.299*rgb[0]+0.587*rgb[1]+0.114*rgb[2];//255是白色x[count]=(pixt[i][j]/255);}}return x;}public static  double sig( double a) throws IOException, ParseException {double b=1/   (1+Math.pow(Math.E , (-1)*(a)       ) ) ;      return b;}public static  void winicy ( int [][]n ,int [][]m, double [][][] twei ,double x ) throws IOException, ParseException {for(int c=0 ;c<cy ;c++){   for(int a=0 ;a<n[c][0] ;a++){for(int b=0 ;b<m[c][0] ;b++){Random rand1 =new Random();int ti1=rand1.nextInt(98)+1;    int xx=1;if(ti1%2==0){xx=-1;}x=(double)x;twei[c][a][b]=xx*((double)ti1/x);}}}}public static  double[] sigmfr( double[] xr ,   double[]  y  ,double w1r [][][],double w2r [][][],double wf1r [][][],double wf2r [][][],int [][]nr,int [][]mr, int [][]kr) throws IOException, ParseException{ for(int a=0 ;a<cy ;a++){for (int w = 0; w < mr[a][0]; w++) {double tem = 0;for (int h = 0; h < nr[a][0] ; h++) {if(a==0){tem = tem + (xr[h]) * w1r[a][h][w];}if(a>0){tem = tem + (ffr[a-1][h]) * w1r[a][h][w];}}fr[a][w] = sig(tem);}for (int w = 0; w < kr[a][0]; w++) {double tem = 0;for (int h = 0; h <mr[a][0]; h++) {tem = tem + fr[a][h] * w2r[a][h][w];              }ffr[a][w] = sig(tem);   }} /************************************///正向到此结束for(int a=cy-1 ;a>-1 ;a--){                  if(a<cy-1){for (int h = 0; h < nr[a+1][0]; h++) {double tem = 0;for (int w = 0; w < mr[a+1][0]; w++) {tem = tem + w1r[a+1][h][w] * ffr[a][h] * (1 - ffr[a][h]) * (dr[a+1][w]);}ddr[a][h] = tem;}}for(int a1=0 ;a1<mr[a][0] ;a1++){for(int b=0 ;b<kr[a][0];b++){if(a<cy-1){wf2r[a][a1][b]=wf2r[a][a1][b]+fr[a][a1]*( ddr[a][b]);}if(a==cy-1){wf2r[a][a1][b]=wf2r[a][a1][b]+fr[a][a1]*( ffr[a][b]-y[b]);}  }}for (int h = 0; h < mr[a][0] ; h++) { double tem=0;for (int w = 0; w < kr[a][0]; w++) {if(a<cy-1){tem=tem+w2r[a][h][w] *fr[a][h]*(1-fr[a][h])*( ddr[a][w]) ;  }if(a==cy-1){tem=tem+w2r[a][h][w] *fr[a][h]*(1-fr[a][h])*( ffr[a][w]-y[w]  ) ;   }  }dr[a][h]=tem;}for (int h = 0; h < nr[a][0] ; h++) {             for (int w = 0; w < mr[a][0]; w++) {if(a>0){wf1r[a][h][w]=wf1r[a][h][w]+ ffr[a-1][h]*dr[a][w] ;}if(a==0){wf1r[a][h][w]=wf1r[a][h][w]+ xr[h]*dr[a][w] ;}}}}/************************************************/double [] fan= new double[kr[cy-1][0]];for (int w = 0; w < kr[cy-1][0]; w++) {fan[w]=ffr[cy-1][w]  ;  //h}   return fan;  }public static  double[] tsigmfr(  double[] xr ,   double w1r [][][],double w2r [][][],double wf1r [][][],double wf2r [][][],int [][]nr,int [][]mr, int [][]kr) throws IOException, ParseException{ for(int a=0 ;a<cy ;a++){for (int w = 0; w < mr[a][0]; w++) {double tem = 0;for (int h = 0; h < nr[a][0] ; h++) {if(a==0){tem = tem + (xr[h]) * w1r[a][h][w];}if(a>0){tem = tem + (ffr[a-1][h]) * w1r[a][h][w];}}fr[a][w] = sig(tem);}for (int w = 0; w < kr[a][0]; w++) {double tem = 0;for (int h = 0; h <mr[a][0]; h++) {tem = tem + fr[a][h] * w2r[a][h][w];                 }ffr[a][w] = sig(tem);  //h}}double [] fan= new double[kr[cy-1][0]];for (int w = 0; w < kr[cy-1][0]; w++) {fan[w]=ffr[cy-1][w]  ;   } return fan;       }public static  String test1( int tcount  ) throws IOException, ParseException { //ini(  );//ini1(  );//p=1e-6;DecimalFormat df = new DecimalFormat( "0.00000000");  winicy(nr, mr, w1r ,weix );   winicy(mr, kr, w2r ,weix );   int flag=0;         int count = 0;double[] jud=new double[kr[cy-1][0]];double dr=0;int batch=tra.length ;for(int at=1 ;at<5000 ; at++ ){  for(int v=0;v<batch;v++){ count++;  y=new double[kr[cy-1][0]];y[v]=1;xr=train[v][at];jud=sigmfr( xr , y  , w1r , w2r , wf1r , wf2r , nr,mr, kr );if(count%1000==0) {System.out.println(df.format(jud[0])+"  "+df.format(jud[1])+"   * " + count+"   "+df.format(Math.abs(jud[0] - y[0]))+" * "+df.format(Math.abs(jud[1] - y[1]))+"  *  "+v +"    "+tcount+"  "+p+" " +dr);}int pan=0;for(int c=0;c<batch;c++){if( Math.abs(jud[c]-y[c])<p ){pan++;}}if(pan==batch){flag=1; break; }}/******************************************/for(int a=0 ;a<cy ;a++){for (int a1=0; a1<mr[a][0]; a1++) {for (int b=0; b<kr[a][0]; b++) {w2r[a][a1][b]=w2r[a][a1][b]-ret*wf2r[a][a1][b]/z;}}for (int a2=0; a2<nr[a][0]; a2++) {for (int b=0; b<mr[a][0]; b++) {w1r[a][a2][b]=w1r[a][a2][b]-ret*wf1r[a][a2][b]/z;    }}}wf1r =new double[cy][1][1];wf2r =new double[cy][1][1];         for(int a=0 ;a<cy ;a++){wf1r[a] =new double[nr[a][0]][mr[a][0]];wf2r[a] =new double[mr[a][0]][kr[a][0]];}           if (flag==1 ){dr=itest( );System.out.println(dr+"  正确率     "+z+"  "+ tcount+" "+p );break;}if(flag==0&&at==4999){at=1;}}String fan="";for (int a = 0; a < kr[cy-1][0]; a++) {fan=fan+jud[a]+",";}fan=fan+count+","+dr+","+p;return fan;}public static  double itest(  ) throws IOException, ParseException {    double []x2=new double[shuru];double c1=0;double c2=0;double rc1=0;for(int count =0 ;count <kr[cy-1][0] ;count++){for ( int i=0; i < test[count].length; i++) {x2=  test[ count][i];double [] jud= new double[kr[cy-1][0]];jud=tsigmfr  (x2 , w1r ,w2r ,wf1r ,wf2r ,nr,mr, kr );DecimalFormat df = new DecimalFormat( "0.0000000");  double max=0.0;for(int a=0 ;a<kr[cy-1][0] ;a++){if(jud[a]>max){max=jud[a];}}int pan=0;for(int a=0 ;a<kr[cy-1][0] ;a++){if(jud[a]==max){pan=fen[a]; }}String show="0";if(pan==fen[count]){c1++;show="对的";}if(pan!=fen[count]){c2++;show="错的";}rc1=c1/(c1+c2);//  System.out.println(pan+"  "+ c1+"  "+c2+" || "+ " * "+df.format(jud[0])+" "+df.format(jud[1])+"     "+rc1+"  "+rc2);}}return rc1;}public static  void t31( ) throws IOException, ParseException { String str[]= new String[200];for(int a=1 ; a<200 ; a++){long sysDate1 = System.currentTimeMillis();String r=test1( a );long sysDate2 = System.currentTimeMillis();  str[a]=r +","+ (sysDate2-sysDate1);//fileWriter5.write(r +","+ (sysDate2-sysDate1) +"\r\n");//fileWriter5.flush();    }for(int a=1 ; a<200 ; a++){fileWriter5.write(str[a] +"\r\n");fileWriter5.flush();  }  }public static  void pauto( ) throws IOException, ParseException { ini(  );ini1(  );fileWriter5=new FileWriter("d:/工业/f/naf.csv");               //***CString ins=read.conv.read( "d:/工业/f/naf3gd数据/3convda.csv");  //***Dins=ins.trim();String[] id    =Pattern.compile(",").split(ins); for(int a= 0 ;a<34 ;a++)        //***(1) 减小{if(id[a].contains("*")){String[] xx   =Pattern.compile("\\*").split(id[a]);p=Double.parseDouble(xx[0].trim()  )*Double.parseDouble(xx[1].trim()  ); System.out.println(id[a]+"  * "+xx[0]+"  * "+xx[1]+"  "+p );}if ( !(id[a].contains("*")) ){p=Double.parseDouble(id[a].trim()  );}long sysDate1 = System.currentTimeMillis(); t31( );long sysDate2 = System.currentTimeMillis();  fileWriter5.write((sysDate2-sysDate1)  +"\r\n");fileWriter5.flush();     }}public static  void r31( ) throws IOException, ParseException { ini(  );FileWriter fileWriter5=new FileWriter("d:/工业/f/naf3数据处理.csv");    //***EString ins= read.conv.read( "d:/工业/f/naf.csv");               //***Fins=ins.trim();String[]  id    =Pattern.compile(",").split(ins);  System.out.println(id.length);int count=0;int bb=4;int k=kr[cy-1][0];double d[] =new double[k+bb];int num=0;int  t=k+bb;double tmax=0;for(int a=0 ;a<id.length/t-1 ;a++){     if(!id[a*t+1].trim().isEmpty() && count<199){System.out.println(id[a*t]+" "+id[a*t+1]+" "+id[a*t+2] +"    "+count );for(int b=0 ;b<k+bb; b++){d[b]=d[b]+Double.parseDouble(id[a*t+b].trim()); }if( Double.parseDouble((id[a*t+3]).trim())>tmax){tmax=Double.parseDouble((id[a*t+3]).trim());}count++;}String tem="";if(count==199){ for(int b=0 ;b<k+bb; b++){if(b!=3){tem=tem+d[b]/199+",";}if(b==3){tem=tem+tmax+",";}}System.out.println(  tem +"  **  "     +a     );count=0;for(int b=0 ;b<k+bb; b++){d[b]=0; }tmax=0;}if(id[(a+1)*t+1].trim().isEmpty() ){tem=tem+ id[(a+1)*t ]+"," ;System.out.println(  tem +"  **  "   +a       );fileWriter5.write( tem  +"\r\n");fileWriter5.flush();tem="";}}    }public static  void r31ave( ) throws IOException, ParseException { ini(  );FileWriter fileWriter5=new FileWriter("d:/工业/f/naf3数据处理.csv");     //***GString ins= read.conv.read( "d:/工业/f/naf.csv");               //***Hins=ins.trim();String[]  id    =Pattern.compile(",").split(ins);  System.out.println(id.length);int count=0;int bb=4;int k=kr[cy-1][0];double d[] =new double[k+bb];int wz=4;int  t=k+bb;double tmax=0;int pnum=199;for(int a=0 ;a<id.length/t-1 ;a++){    if(!id[a*t+1].trim().isEmpty() && count<pnum){for(int b=0 ;b<k+bb; b++){d[b]=d[b]+Double.parseDouble(id[a*t+b].trim()); }System.out.println(id[a*t]+" "+id[a*t+1]+" "+id[a*t+2] +"    "+count +"  "+tmax );count++;}String tem="";if(count==pnum){for(int b=0 ;b<k+bb; b++){// if(b!=3){tem=tem+d[b]/pnum+",";}}System.out.println(  tem +"  **  "     +a     );count=0;for(int b=0 ;b<k+bb; b++){d[b]=0; }tmax=0;}if(id[(a+1)*t+1].trim().isEmpty() ){tem=tem+ id[(a+1)*t ]+"," ;System.out.println(  tem +"  **  "   +a       );fileWriter5.write( tem  +"\r\n");fileWriter5.flush();tem=""; }}}public static void main(String[] args) throws IOException, ParseException {pauto( );//r31( );//r31ave( );}}

使用说明

一.13个子程序

1.Ini()

初始化权重数组w1r,w2r;初始化权重差值数组wf1r,wf2r;初始化中间数组fr,ffr;初始化差值数组dr,ddr;初始化各层节点数nr,mr,kr;初始化输入数组xr;初始化输出数组y

2.Ini1()

将训练集读入数组train[][][]中,将测试集读入test[][][]中

3.pix( String a,int shuru )

读出图片各点的像素,a是图片的路径,shuru用来控制输入图片的大小,这个不是池化过程,比如shuru=9*9是每隔3个点取一个点,shuru=7*7就是每隔4个点取一个点,shuru=28*28就是mnist的原图不变

4.sig( double a)

sigmoid函数

5.winicy ( int [][]n ,int [][]m, double [][][] twei ,double x )

为权重赋值

6.sigmfr( double[] xr ,   double[]  y  , double w1r [][][],double w2r [][][],

double wf1r [][][],double wf2r [][][],int [][]nr,int [][]mr, int [][]kr)

程序的最基本步骤,正向迭代和反向传导

7.tsigmfr(  double[] xr ,   double w1r [][][],double w2r [][][],

double wf1r [][][],double wf2r [][][],int [][]nr,int [][]mr, int [][]kr )

用于测试,只包括正向迭代

8.test1( int tcount  )

主调用程序if( Math.abs(jud[c]-y[c])<p )是用输出函数与目标函数的差值作为迭代终止条件。tcount表示调用次数。

可以用test1( 0 )的方式单次调用test1.

神经网络最为精髓的权重共享操作就是在这步完成,w2r[a][a1][b]=w2r[a][a1][b]-ret*wf2r[a][a1][b]/z;因为这一步,对应两组输入的权重得以完成耦合。

当用test1(0)的单次调用方式调用程序时,需要将ini()和 ini1()程序开启,并给p(δ)赋值

9.itest(  )

测试程序

10.t31( )

这一步是可选操作,让test1迭代199次用来统计平均值,并记录每次迭代数据。

11.pauto( )

调用t31(),并完成对主参数p(δ)的赋值,可以在得到的表格中观察到,在δ不变的前提下,迭代次数是离散分布而且是高度特征的。

12.r31( )

数据处理,用于计算最大值,启动r31()程序前要把pauto()程序关掉,//pauto().否则数据会被重写。

13.r31ave( )

数据处理,取平均值,由于空格问题需要手动在naf.csv的最后一行最后一列手动的输入一个字符,可以是任意一个字符。

比如

6.97E-05

0.999946

4644

0.984095

9.00E-05

109

7.81E-05

0.99995

3862

0.982107

9.00E-05

94

16859

       

*

启动r31ave()程序前要把pauto()程序关掉,//pauto().否则数据会被重写。

二.6个变量

δ

训练集差异

学习率

权重

隐藏层节点数

卷积核数量

网络层数

 

不变

增加

减小

增大

减小

有最优值

增加

网络性能增加

               

δ

训练集差异

学习率

权重

隐藏层节点数

卷积核数量

网络层数

 

减小

不变

不变

不变

不变

不变

不变

网络性能增加

在这个网络中只有7个变量可以影响网络的分类性能,其中收敛标准δ,学习率,权重和网络层数是等效的变量,比如增加网络层数在一定范围内可以等效的通过减小δ来实现。隐藏层节点数需要求出效率最优值,卷积核数量需要用实验的办法找到最优值。但即便在这两个最优值不知道的情况下也可以通过减小等效参数δ的办法来单向的提高网络性能。将δ设为1e-6几乎总可以保证网络有一个不错的性能。而不必估计与之对应的迭代次数,这是这个网络调参最为便捷的地方。

1.δ(p)…594(行)

2.训练集和测试集…33

3.学习率…15

4.权重…16

5.隐藏层节点数…36

7.层数…20

这个网络没有卷积核因此只有6个参数.,

这个网络只能实现奇数行网络比如3,5,7,9,11,13。其中3到11层网络的性能是稳定可期待的,但是13层网络的性能并不稳定。因此有效的层数只有5个。

节点数只能用1个循环节来赋值,比如当

int shuru=9*9;

int yc=30;

int shuchu=49;

3层是81*30*分类数

5层是81*30*49*30*分类数

具体调参过程请参考《调参总结》

三.8个路径

A…126…训练集所在位置

B…139…测试集所在位置

C…588…测试数据输出位置

D…589…收敛标准δ(p)的数据

E…622…处理后的数据输出位置

F…624…与C相同

G…704…与E相同

H…706…与C相同

这8个路径必须更改为本地路径,否则程序不能正常运行。

训练集的10个数字分别装到10个文件夹里面,

测试集的10个数字也是分别装到10个文件夹里面,但是文件夹的命名方式是b0,b1…

String sf="b"+fen[a]; …138 也可以在第138行更改这个命名规则

四.标定数据

将参数设定为

static double ret=0.1; //学习率      ***(3)  减小

static double weix=100;//权重          ***(4)  减小

static int cy=1; //层数 ***(7)

static int[] tra= {0,2};  //训练集

static int[] fen= {0,2};  //测试集***(2)

static int yc=30;       //***(5)  减小

for(int a= 0 ;a<34 ;a++)          //***(1) 减小

在大约13min内可以得到如下表格的数据,迭代次数和平均准确率和最大准确率应该是高度一致的,收敛时间与机器的性能有关,有可能不同。

81*30*2

               

f2[0]

f2[1]

迭代次数n

平均准确率p-ave

δ

耗时ms/次

耗时ms/199次

耗时 min/199

最大值p-max

0.522324

0.466338

4.824121

0.527528

0.5

17.66834

3516

0.0586

0.804672

0.517923

0.488976

10.60302

0.559235

0.4

16.8995

3363

0.05605

0.818588

0.480915

0.527382

32.92462

0.685667

0.3

17.47739

3478

0.057967

0.917992

0.45703

0.546234

68.78894

0.797262

0.2

18

3582

0.0597

0.963718

0.507829

0.48911

155.2965

0.911606

0.1

19.26131

3833

0.063883

0.968688

0.318766

0.681292

492.8593

0.960129

0.01

25.47739

5086

0.084767

0.977634

0.065961

0.934053

1295.281

0.975169

0.001

40.68342

8096

0.134933

0.982604

0.050842

0.949179

1368.503

0.975409

9.00E-04

41.07035

8173

0.136217

0.983101

0.035695

0.964281

1426.709

0.976148

8.00E-04

42.35678

8429

0.140483

0.983101

0.030628

0.969389

1494.201

0.976238

7.00E-04

43.52764

8662

0.144367

0.985586

0.050617

0.94937

1667.829

0.976875

6.00E-04

46.60804

9275

0.154583

0.986581

0.010398

0.989601

1749.307

0.977357

5.00E-04

47.70854

9509

0.158483

0.986581

0.015357

0.984639

1875.171

0.977389

4.00E-04

50.34673

10019

0.166983

0.985089

0.005238

0.994751

2184.286

0.979382

3.00E-04

56.21106

11186

0.186433

0.986083

0.010197

0.989805

2582.925

0.97974

2.00E-04

63.26131

12589

0.209817

0.985089

0.01012

0.989879

3498.412

0.981728

1.00E-04

84.22111

16760

0.279333

0.987078

6.47E-05

0.999938

3645.025

0.981758

9.00E-05

84.13568

16743

0.27905

0.987078

0.005083

0.994919

3840.156

0.982055

8.00E-05

87.79899

17472

0.2912

0.987575

4.83E-05

0.999951

4077.126

0.982707

7.00E-05

92.61307

18445

0.307417

0.988072

0.005068

0.994932

4212.678

0.982557

6.00E-05

93.86432

18695

0.311583

0.987575

3.61E-05

0.999964

4589.568

0.982902

5.00E-05

101.6683

20232

0.3372

0.988072

0.005054

0.994945

5167.663

0.983454

4.00E-05

113.1709

22521

0.37535

0.988072

0.005047

0.994953

5821.111

0.983354

3.00E-05

125.2261

24935

0.415583

0.988569

1.49E-05

0.999985

6976.513

0.983821

2.00E-05

145.2412

28903

0.481717

0.987575

7.47E-06

0.999993

9615.879

0.983631

1.00E-05

193.8141

38569

0.642817

0.988569

6.46E-06

0.999993

9692.05

0.983736

9.00E-06

194.9598

38797

0.646617

0.989066

5.81E-06

0.999994

10012.85

0.984148

8.00E-06

201.0754

40014

0.6669

0.988569

5.07E-06

0.999995

10419.32

0.983961

7.00E-06

207.5176

41296

0.688267

0.988072

4.29E-06

0.999996

11089.11

0.9844

6.00E-06

222.4523

44268

0.7378

0.989066

3.58E-06

0.999996

12141.85

0.984138

5.00E-06

240.0804

47776

0.796267

0.988072

0.005028

0.994972

12888.37

0.984478

4.00E-06

254.397

50625

0.84375

0.989563

2.11E-06

0.999998

13944.59

0.9849

3.00E-06

275.7286

54870

0.9145

0.989066

1.50E-06

0.999999

16152.7

0.98498

2.00E-06

315.6784

62820

1.047

0.988569

7.15E-07

0.999999

20551.51

0.985886

1.00E-06

395.9397

78792

1.3132

0.99006

标定表格的第5列δ列就是程序第589行的路径D的表格,可以将标定数据表格的其他列都删除,将δ列置于第一列就是表格3convda.csv的内容。

五.极限性能测试

使用三层的网络不用卷积核,用mnist数据集,10分类测试网络的实用性能

参数设置方案是

static double ret=0.1; //学习率      ***(3)  减小

static double weix=1000;//权重          ***(4)  减小

static int cy=1; //层数 ***(7)

static int[] tra= {0,1,2,3,4,5,6,7,8,9};  //训练集

static int[] fen= {0,1,2,3,4,5,6,7,8,9};  //测试集

static int n=784;

static int m=300;   //***(5)  减小

static int k=10;

for(int a= 60 ;a<61 ;a++)         //***(1) 减小

迭代次数n

准确率

δ

耗时ms/次

耗时ms/199次

6802425

0.984858

1.00E-09

11319060

188.651

6730004

0.984156

1.00E-09

14988660

249.811

6249665

0.984456

1.00E-09

9229857

153.831

6290676

0.983654

1.00E-09

11362439

189.374

5129416

0.982852

1.00E-09

7887187

131.4531

4464786

0.982952

1.00E-09

6659705

110.9951

5305764

0.983153

1.00E-09

7999463

133.3244

6067846

0.983053

1.00E-09

9387251

156.4542

5218186

0.982551

1.00E-09

8619121

143.652

5327884

0.982952

1.00E-09

7842863

130.7144

4909916

0.983153

1.00E-09

7628994

127.1499

5789196

0.982451

1.00E-09

8916027

148.6005

5156298

0.98225

1.00E-09

7897897

131.6316

共测试了13组,平均需要564万次迭代,耗时大概153min,准确率最大值98.48%。

多层神经网络Java代码800行相关推荐

  1. Protobuf生成Java代码(命令行)

    1.说明 本文介绍Protobuf生成Java代码的方法, 下载必须的Protobuf工具, 然后通过命令行, 把.proto文件生成Java代码. 2.准备Protobuf工具 2.1.获取prot ...

  2. java记录代码执行位置_记录执行的java代码的行号

    PHP interperts的代码,这意味着它每次运行程序时运行源代码.随着代码的读取(这使得行号打印输出变得微不足道),这样做的好处就在于它.然而,由于您无法进行深入优化(或进行任何运行前错误检查) ...

  3. Java代码实现行转列

    文章目录 前言 一.如何转换? 二.转换步骤 前言 最近在写业务的时候,遇到一个需求,要求把数据库的数据行,根据某个维度,把行转换为列去显示.如下图 说明: 系统里某个数据有一系列属性,属性值会根据某 ...

  4. Protobuf生成Java代码(Maven)

    1.说明 本文介绍Protobuf生成Java代码的方法, 配置对应的Maven插件, 把.proto文件生成Java代码. 2.插件配置 创建Maven工程grpc-compile, 修改pom.x ...

  5. 实验三 多层神经网络

    一.实验目的 (1)学习并掌握常见的机器学习方法: (2)能够结合所学的python知识实现机器学习算法: (3)能够用所学的机器学习算法解决实际问题. 二.实验内容与要求 (1)理解多层神经网络的架 ...

  6. 如何用70行Java代码实现神经网络算法

    为什么80%的码农都做不了架构师?>>>    http://geek.csdn.net/news/detail/56086 对于现在流行的深度学习,保持学习精神是必要的--程序员尤 ...

  7. 如何用70行Java代码实现深度神经网络算法

    对于现在流行的深度学习,保持学习精神是必要的--程序员尤其是架构师永远都要对核心技术和关键算法保持关注和敏感,必要时要动手写一写掌握下来,先不用关心什么时候用到--用不用是政治问题,会不会写是技术问题 ...

  8. bp神经网络预测python代码_机器学习之多层神经网络(附Python代码和数据)

    1 引言 多层神经网络,Multiple-layers Perceptron (MLP),又被称为多层感知机,是机器学习中深度学习的典型算法.关于多层神经网络的算法原理,我们在Stata和R实现的文章 ...

  9. excel总行数 java_计算Excel工作表列中的行数(提供的Java代码)

    参考我之前的问题 How to calculate number of rows in a column of Excel document using Java,我能够计算给定表格中的总列数.现在, ...

最新文章

  1. 测试博客园Markdown 表格
  2. 基础回顾(Map、==/equals()/hashcode())
  3. 20159206《网络攻防实践》第五周学习总结
  4. java命令框编译代码的方式_在命令行模式下如何编译运行Java代码
  5. java只有jre_只安装了jre可以运行java程序吗
  6. The Greatest C++ project
  7. 批量查询手机号码运营商信息
  8. Vulkan教程 - 18 阶段性总结
  9. 计算机课程设计红绿灯,labview红绿灯课程设计报告
  10. 读计算机专业买什么笔记本电脑好?你算问对人了
  11. 未来互联网+大数据时代,DT革命互联网大数据应用简析
  12. 局域网传输文件的几种方法盘点
  13. 控制系统中带宽的理解
  14. dede密码修改 php,dede忘记后台密码修改程序
  15. 使用python批量解压7z格式压缩包
  16. mysql 100w 查询耗时4秒_MySql百万数据0秒筛选查询
  17. 抖音中的视频怎么使用手机录制 安卓手机录屏软件哪个好
  18. 数值分析matlab最小二乘法,数值分析 最小二乘 matlab
  19. 【每日一句】名人名言学英语(11.26)
  20. 互联网圈子,黄进磊竟然把它解释的如此霸气!

热门文章

  1. [MIPS汇编语言]简单排序实现
  2. 介绍一种导入文件夹中图片数据集的方法
  3. xtrabackup备份mysql_配置xtrabackup备份mysql数据库
  4. mysql 分时统计_mysql中数据统计的技巧备忘录
  5. vs code中使用Astyle排版C/C++代码
  6. MySql基础入门-mysql体系结构
  7. 推荐一个妹子,播报汽车新闻
  8. MYSQL数据库性能调优之六:备份
  9. 我泡在GitHub上的177天 by Ryan Seys
  10. T-Sql 实现类似访问数组变量的操作