欢迎来到天天文库
浏览记录
ID:51686413
大小:33.93 KB
页数:5页
时间:2020-03-15
《BP神经网络算法java实现.docx》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、BP神经网络算法java实现packagebackp;importjava.*;importjava.awt.*;importjava.io.*;importjava.util.Scanner;//byrealmagicianimportorg.omg.CORBA.portable.InputStream;publicclassbackpro{publicstaticvoidmain(Stringargs[]){Stringfilename=newString("delta.in");try{FileInputStreamfileInputStream=newFileInputStream(f
2、ilename);ScannersinScanner=newScanner(fileInputStream);intattN,hidN,outN,samN;attN=sinScanner.nextInt();outN=sinScanner.nextInt();hidN=sinScanner.nextInt();samN=sinScanner.nextInt();//System.out.println(attN+""+outN+""+hidN+""+samN);doublesamin[][]=newdouble[samN][attN];doublesamout[][]=newdouble[sa
3、mN][outN];for(inti=0;i4、System.out.print(bp2.dw1[i][j]+"");System.out.println();}for(inti=0;i5、testin[i]=testinScanner.nextDouble();}testout=bp2.getResault(testin);for(inti=0;i6、ntattN;//输入单元个数intoutN;//输出单元个数inttimes;//迭代次数doublerate;//学习速率booleantrained=false;//保证在得结果前,先训练BP2(intattN,intoutN,inthidN,intsamN,inttimes,doublerate){this.attN=attN;this.outN=outN;this.hidN=hidN;this.samN=samN;dw1=newdouble[hidN][attN+1];//每行最后一个是阈值w0for(inti=0;i7、(intj=0;j<=attN;++j)dw1[i][j]=Math.random()/2;}dw2=newdouble[outN][hidN+1];//输出层权值,每行最后一个是阈值w0for(inti=0;i
4、System.out.print(bp2.dw1[i][j]+"");System.out.println();}for(inti=0;i5、testin[i]=testinScanner.nextDouble();}testout=bp2.getResault(testin);for(inti=0;i6、ntattN;//输入单元个数intoutN;//输出单元个数inttimes;//迭代次数doublerate;//学习速率booleantrained=false;//保证在得结果前,先训练BP2(intattN,intoutN,inthidN,intsamN,inttimes,doublerate){this.attN=attN;this.outN=outN;this.hidN=hidN;this.samN=samN;dw1=newdouble[hidN][attN+1];//每行最后一个是阈值w0for(inti=0;i7、(intj=0;j<=attN;++j)dw1[i][j]=Math.random()/2;}dw2=newdouble[outN][hidN+1];//输出层权值,每行最后一个是阈值w0for(inti=0;i
5、testin[i]=testinScanner.nextDouble();}testout=bp2.getResault(testin);for(inti=0;i6、ntattN;//输入单元个数intoutN;//输出单元个数inttimes;//迭代次数doublerate;//学习速率booleantrained=false;//保证在得结果前,先训练BP2(intattN,intoutN,inthidN,intsamN,inttimes,doublerate){this.attN=attN;this.outN=outN;this.hidN=hidN;this.samN=samN;dw1=newdouble[hidN][attN+1];//每行最后一个是阈值w0for(inti=0;i7、(intj=0;j<=attN;++j)dw1[i][j]=Math.random()/2;}dw2=newdouble[outN][hidN+1];//输出层权值,每行最后一个是阈值w0for(inti=0;i
6、ntattN;//输入单元个数intoutN;//输出单元个数inttimes;//迭代次数doublerate;//学习速率booleantrained=false;//保证在得结果前,先训练BP2(intattN,intoutN,inthidN,intsamN,inttimes,doublerate){this.attN=attN;this.outN=outN;this.hidN=hidN;this.samN=samN;dw1=newdouble[hidN][attN+1];//每行最后一个是阈值w0for(inti=0;i7、(intj=0;j<=attN;++j)dw1[i][j]=Math.random()/2;}dw2=newdouble[outN][hidN+1];//输出层权值,每行最后一个是阈值w0for(inti=0;i
7、(intj=0;j<=attN;++j)dw1[i][j]=Math.random()/2;}dw2=newdouble[outN][hidN+1];//输出层权值,每行最后一个是阈值w0for(inti=0;i
此文档下载收益归作者所有