BP神经网络实现Java代码.docx

上传人:scccc 文档编号:13628158 上传时间:2022-01-20 格式:DOCX 页数:3 大小:19.87KB
返回 下载 相关 举报
BP神经网络实现Java代码.docx_第1页
第1页 / 共3页
BP神经网络实现Java代码.docx_第2页
第2页 / 共3页
BP神经网络实现Java代码.docx_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《BP神经网络实现Java代码.docx》由会员分享,可在线阅读,更多相关《BP神经网络实现Java代码.docx(3页珍藏版)》请在三一文库上搜索。

1、BP神经网络实现(Java代码)神经网络的原理虽然理解起来不难,但是要是想实现它,还是需要做一些工作的,并且有很多细节性的东 西需要注意。通过参阅各种相关资料,以及参考网络上已有的资源,自己写了一个含有一个隐含层,且只 能有一个输出单元的简单的 BP网络,经过测试,达到了预期的效果。0或1,需要说明的是,神经网络的每个输入都在0,1中,输出也在0,1中,在使用神经网络解决实际问题的时候,还需要对实际问题的输入输出进行归一化处理。另外,尽量不要使得神经网络的输入或输出接近于 这样会影响拟合效果。我用正弦函数进行了一次测试,效果如图所示:以下是相关的代码:i.神经网络代码java view pla

2、incopy1. package pkg1;2.3. import java.util.Scanner;4.5. /*6. *7. */8. public class TestNeuro 10. .11.12.13.14.15.16.17.privateint INPUT_DIM= 1;privateint HIDDEN_DIM= 20;private double LEARNING_RATE=0.05 ;double input_hidden_weights=new double INPUT_DIMHIDDEN_DIM;double hidden_output_weights= new do

3、uble HIDDEN_DIM;double hidden_thresholds= new double HIDDEN_DIM;18.19.20.21.22.23.24.25.26.27.28.29.public static void main(Stringargs)Scanner in=new Scanner(System.in);TestNeuro neuro=new TestNeuro(1,5);neuro.initialize();for (int i= 0;i 10000 ;i+)double 口 input= new double 1 ;input0=Math.random();

4、double expectedOutput=input 0*input0;System.out.println(input : +input0+ttexpectedOutput :+expectedOutput);System.out.println(predict before training : +neuro.predict (input);neuro.trainOnce(input, expectedOutput);System.out.println(predict after training : +neuro.predict( input);double output_thres

5、hold;30. in.next();31. 32. while (true )33. neuro.printLinks();34. double 口 input= new double 1 ;35. input0=in.nextDouble();36. double expectedOutput=in.nextDouble();37. System.out.println(predict before training : +neuro.predict(input);38. neuro.trainOnce(input, expectedOutput);39. System.out.println(predict after training : +neuro.predict(input);40.41. 42. 43.44. public TestNeuro( int input_dimension, int hidden_dimension)45. this.INPUT_DIM=input_dimension;46. this.HIDDEN_DIM=hidden_dimension;47. this.initialize();

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1