基于神经网络的马尾松毛虫精细化预报Matlab建模试验(20页).doc

上传人:1595****071 文档编号:37053437 上传时间:2022-08-29 格式:DOC 页数:20 大小:600.50KB
返回 下载 相关 举报
基于神经网络的马尾松毛虫精细化预报Matlab建模试验(20页).doc_第1页
第1页 / 共20页
基于神经网络的马尾松毛虫精细化预报Matlab建模试验(20页).doc_第2页
第2页 / 共20页
点击查看更多>>
资源描述

《基于神经网络的马尾松毛虫精细化预报Matlab建模试验(20页).doc》由会员分享,可在线阅读,更多相关《基于神经网络的马尾松毛虫精细化预报Matlab建模试验(20页).doc(20页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、-基于神经网络的马尾松毛虫精细化预报Matlab建模试验-第 20 页基于神经网络的马尾松毛虫精细化预报Matlab建模试验张国庆(安徽省潜山县林业局)1.数据来源马尾松毛虫发生量、发生期数据来源于潜山县监测数据,气象数据来源于国家气候中心。2.数据预处理为了体现马尾松毛虫发生发展时间上的完整性,在数据处理时,将越冬代数据与上一年第二代数据合并,这样,就在时间上保持了一个马尾松毛虫世代的完整性,更便于建模和预测。(1)气象数据处理根据松毛虫综合管理、中国松毛虫等学术资料以及近年来有关马尾松毛虫监测预报学术论文,初步选择与松毛虫发生量、发生期有一定相关性气象因子,包括卵期极低气温,卵期平均气温,

2、卵期积温(日度),卵期降雨量,第1、2龄极低气温,第1、2龄平均气温,第1、2龄积温(日度),第12龄降雨量,幼虫期极低气温,幼虫期平均气温,幼虫期积温(日度),幼虫期降雨量,世代极低气温,世代平均气温,世代积温(日度),世代降雨量共16个变量。将来自于国家气候中心的气象原始数据,按年度分世代转换成上述16个变量数据系列。(2)发生量数据处理为了在建模时分析发生强度,在对潜山县19832014年原始监测数据预处理时,按照“轻”、“中”、“重”3个强度等级,分类按世代逐年汇总。(3)发生期数据处理首先对潜山县19832014年原始发生期监测数据按世代逐年汇总,然后日期数据转换成日历天,使之数量化

3、,以便于建模分析。3.因子变量选择通过相关性分析和建模试验比较,第一代发生量因子变量选择第1、2龄极低气温,卵期极低气温,上一代防治效果,上一代防治面积;第二代发生量因子变量选择第1、2龄极低气温,卵期极低气温,上一代防治效果,上一代防治面积,第1、2龄降雨量,卵期降雨量;第一代幼虫高峰期因子变量选择第1、2龄平均气温,第1、2龄积温(日度),第1、2龄极低气温,卵期极低气温;第二代幼虫高峰期因子变量选择成虫始见期,卵期平均气温,卵期积温(日度),第1、2龄极低气温。将第一代发生量变量命名为s1y,因变量命名为s1x;第二代发生量变量命名为s2y,因变量命名为s2x;第一代幼虫高峰期变量命名为

4、t1y,因变量命名为t1x;第二代幼虫高峰期变量命名为t2y,因变量命名为t2x。4.第一代发生量建模试验4.1程序代码程序代码(Simple Script)为:% Solve an Input-Output Fitting problem with a Neural Network% Script generated by Neural Fitting app% Created Wed Oct 28 19:28:48 CST 2015% This script assumes these variables are defined:% s1x - input data.% s1y - tar

5、get data.x = s1x;t = s1y;% Choose a Training Function% For a list of all training functions type: help nntrain% trainlm is usually fastest.% trainbr takes longer but may be better for challenging problems.% trainscg uses less memory. NFTOOL falls back to this in low memory situations.trainFcn = trai

6、nlm; % Levenberg-Marquardt% Create a Fitting NetworkhiddenLayerSize = 10;net = fitnet(hiddenLayerSize,trainFcn);% Setup Division of Data for Training, Validation, Testingnet.divideParam.trainRatio = 90/100;net.divideParam.valRatio = 5/100;net.divideParam.testRatio = 5/100;% Train the Networknet,tr =

7、 train(net,x,t);% Test the Networky = net(x);e = gsubtract(t,y);performance = perform(net,t,y)% View the Networkview(net)% Plots% Uncomment these lines to enable various plots.%figure, plotperform(tr)%figure, plottrainstate(tr)%figure, plotfit(net,x,t)%figure, plotregression(t,y)%figure, ploterrhist

8、(e)程序代码(Advanced Script)为:% Solve an Input-Output Fitting problem with a Neural Network% Script generated by Neural Fitting app% Created Wed Oct 28 19:29:03 CST 2015% This script assumes these variables are defined:% s1x - input data.% s1y - target data.x = s1x;t = s1y;% Choose a Training Function%

9、For a list of all training functions type: help nntrain% trainlm is usually fastest.% trainbr takes longer but may be better for challenging problems.% trainscg uses less memory. NFTOOL falls back to this in low memory situations.trainFcn = trainlm; % Levenberg-Marquardt% Create a Fitting Networkhid

10、denLayerSize = 10;net = fitnet(hiddenLayerSize,trainFcn);% Choose Input and Output Pre/Post-Processing Functions% For a list of all processing functions type: help nnprocessnet.input.processFcns = removeconstantrows,mapminmax;net.output.processFcns = removeconstantrows,mapminmax;% Setup Division of

11、Data for Training, Validation, Testing% For a list of all data division functions type: help nndividenet.divideFcn = dividerand; % Divide data randomlynet.divideMode = sample; % Divide up every samplenet.divideParam.trainRatio = 90/100;net.divideParam.valRatio = 5/100;net.divideParam.testRatio = 5/1

12、00;% Choose a Performance Function% For a list of all performance functions type: help nnperformancenet.performFcn = mse; % Mean squared error% Choose Plot Functions% For a list of all plot functions type: help nnplotnet.plotFcns = plotperform,plottrainstate,ploterrhist, . plotregression, plotfit;%

13、Train the Networknet,tr = train(net,x,t);% Test the Networky = net(x);e = gsubtract(t,y);performance = perform(net,t,y)% Recalculate Training, Validation and Test PerformancetrainTargets = t .* tr.trainMask1;valTargets = t .* tr.valMask1;testTargets = t .* tr.testMask1;trainPerformance = perform(net

14、,trainTargets,y)valPerformance = perform(net,valTargets,y)testPerformance = perform(net,testTargets,y)% View the Networkview(net)% Plots% Uncomment these lines to enable various plots.%figure, plotperform(tr)%figure, plottrainstate(tr)%figure, plotfit(net,x,t)%figure, plotregression(t,y)%figure, plo

15、terrhist(e)% Deployment% Change the (false) values to (true) to enable the following code blocks.if (false) % Generate MATLAB function for neural network for application deployment % in MATLAB scripts or with MATLAB Compiler and Builder tools, or simply % to examine the calculations your trained neu

16、ral network performs. genFunction(net,myNeuralNetworkFunction); y = myNeuralNetworkFunction(x);endif (false) % Generate a matrix-only MATLAB function for neural network code % generation with MATLAB Coder tools. genFunction(net,myNeuralNetworkFunction,MatrixOnly,yes); y = myNeuralNetworkFunction(x);

17、endif (false) % Generate a Simulink diagram for simulation or deployment with. % Simulink Coder tools. gensim(net);end4.2网络训练过程网络训练为:图1 第一代发生量网络训练过程4.3训练结果训练结果为:图2 第一代发生量网络训练结果训练样本、验证样本、测试样本的R值分别为0.875337、-1和1。误差直方图为:图3 第一代发生量网络训练结果误差直方图训练样本、验证样本、测试样本、所有数据回归图为:图4 第一代发生量网络训练结果回归图验证样本和测试样本R值均为1。5.第二代发

18、生量建模试验5.1程序代码程序代码(Simple Script)为:% Solve an Input-Output Fitting problem with a Neural Network% Script generated by Neural Fitting app% Created Wed Oct 28 20:04:18 CST 2015% This script assumes these variables are defined:% s2x - input data.% s2y - target data.x = s2x;t = s2y;% Choose a Training Fu

19、nction% For a list of all training functions type: help nntrain% trainlm is usually fastest.% trainbr takes longer but may be better for challenging problems.% trainscg uses less memory. NFTOOL falls back to this in low memory situations.trainFcn = trainlm; % Levenberg-Marquardt% Create a Fitting Ne

20、tworkhiddenLayerSize = 10;net = fitnet(hiddenLayerSize,trainFcn);% Setup Division of Data for Training, Validation, Testingnet.divideParam.trainRatio = 90/100;net.divideParam.valRatio = 5/100;net.divideParam.testRatio = 5/100;% Train the Networknet,tr = train(net,x,t);% Test the Networky = net(x);e

21、= gsubtract(t,y);performance = perform(net,t,y)% View the Networkview(net)% Plots% Uncomment these lines to enable various plots.%figure, plotperform(tr)%figure, plottrainstate(tr)%figure, plotfit(net,x,t)%figure, plotregression(t,y)%figure, ploterrhist(e)程序代码(Advanced Script)为:% Solve an Input-Outp

22、ut Fitting problem with a Neural Network% Script generated by Neural Fitting app% Created Wed Oct 28 20:04:31 CST 2015% This script assumes these variables are defined:% s2x - input data.% s2y - target data.x = s2x;t = s2y;% Choose a Training Function% For a list of all training functions type: help

23、 nntrain% trainlm is usually fastest.% trainbr takes longer but may be better for challenging problems.% trainscg uses less memory. NFTOOL falls back to this in low memory situations.trainFcn = trainlm; % Levenberg-Marquardt% Create a Fitting NetworkhiddenLayerSize = 10;net = fitnet(hiddenLayerSize,

24、trainFcn);% Choose Input and Output Pre/Post-Processing Functions% For a list of all processing functions type: help nnprocessnet.input.processFcns = removeconstantrows,mapminmax;net.output.processFcns = removeconstantrows,mapminmax;% Setup Division of Data for Training, Validation, Testing% For a l

25、ist of all data division functions type: help nndividenet.divideFcn = dividerand; % Divide data randomlynet.divideMode = sample; % Divide up every samplenet.divideParam.trainRatio = 90/100;net.divideParam.valRatio = 5/100;net.divideParam.testRatio = 5/100;% Choose a Performance Function% For a list

26、of all performance functions type: help nnperformancenet.performFcn = mse; % Mean squared error% Choose Plot Functions% For a list of all plot functions type: help nnplotnet.plotFcns = plotperform,plottrainstate,ploterrhist, . plotregression, plotfit;% Train the Networknet,tr = train(net,x,t);% Test

27、 the Networky = net(x);e = gsubtract(t,y);performance = perform(net,t,y)% Recalculate Training, Validation and Test PerformancetrainTargets = t .* tr.trainMask1;valTargets = t .* tr.valMask1;testTargets = t .* tr.testMask1;trainPerformance = perform(net,trainTargets,y)valPerformance = perform(net,va

28、lTargets,y)testPerformance = perform(net,testTargets,y)% View the Networkview(net)% Plots% Uncomment these lines to enable various plots.%figure, plotperform(tr)%figure, plottrainstate(tr)%figure, plotfit(net,x,t)%figure, plotregression(t,y)%figure, ploterrhist(e)% Deployment% Change the (false) val

29、ues to (true) to enable the following code blocks.if (false) % Generate MATLAB function for neural network for application deployment % in MATLAB scripts or with MATLAB Compiler and Builder tools, or simply % to examine the calculations your trained neural network performs. genFunction(net,myNeuralN

30、etworkFunction); y = myNeuralNetworkFunction(x);endif (false) % Generate a matrix-only MATLAB function for neural network code % generation with MATLAB Coder tools. genFunction(net,myNeuralNetworkFunction,MatrixOnly,yes); y = myNeuralNetworkFunction(x);endif (false) % Generate a Simulink diagram for

31、 simulation or deployment with. % Simulink Coder tools. gensim(net);end5.2网络训练过程网络训练为:图5 第二代发生量网络训练过程5.3训练结果训练结果为:图6 第二代发生量网络训练结果训练样本、验证样本、测试样本的R值分别为0.942388、0.999999和1。误差直方图为:图7 第二代发生量网络训练结果误差直方图训练样本、验证样本、测试样本、所有数据回归图为:图8 第二代发生量网络训练结果回归图验证样本和测试样本R值均为1,训练样本R=0.94239,所有数据R=0.89479。6.第一代幼虫高峰期建模试验6.1程序

32、代码程序代码(Simple Script)为:% Solve an Input-Output Fitting problem with a Neural Network% Script generated by Neural Fitting app% Created Wed Oct 28 20:16:32 CST 2015% This script assumes these variables are defined:% t1x - input data.% t1y - target data.x = t1x;t = t1y;% Choose a Training Function% For

33、 a list of all training functions type: help nntrain% trainlm is usually fastest.% trainbr takes longer but may be better for challenging problems.% trainscg uses less memory. NFTOOL falls back to this in low memory situations.trainFcn = trainlm; % Levenberg-Marquardt% Create a Fitting Networkhidden

34、LayerSize = 10;net = fitnet(hiddenLayerSize,trainFcn);% Setup Division of Data for Training, Validation, Testingnet.divideParam.trainRatio = 90/100;net.divideParam.valRatio = 5/100;net.divideParam.testRatio = 5/100;% Train the Networknet,tr = train(net,x,t);% Test the Networky = net(x);e = gsubtract

35、(t,y);performance = perform(net,t,y)% View the Networkview(net)% Plots% Uncomment these lines to enable various plots.%figure, plotperform(tr)%figure, plottrainstate(tr)%figure, plotfit(net,x,t)%figure, plotregression(t,y)%figure, ploterrhist(e)程序代码(Advanced Script)为:% Solve an Input-Output Fitting

36、problem with a Neural Network% Script generated by Neural Fitting app% Created Wed Oct 28 20:17:08 CST 2015% This script assumes these variables are defined:% t1x - input data.% t1y - target data.x = t1x;t = t1y;% Choose a Training Function% For a list of all training functions type: help nntrain% t

37、rainlm is usually fastest.% trainbr takes longer but may be better for challenging problems.% trainscg uses less memory. NFTOOL falls back to this in low memory situations.trainFcn = trainlm; % Levenberg-Marquardt% Create a Fitting NetworkhiddenLayerSize = 10;net = fitnet(hiddenLayerSize,trainFcn);%

38、 Choose Input and Output Pre/Post-Processing Functions% For a list of all processing functions type: help nnprocessnet.input.processFcns = removeconstantrows,mapminmax;net.output.processFcns = removeconstantrows,mapminmax;% Setup Division of Data for Training, Validation, Testing% For a list of all

39、data division functions type: help nndividenet.divideFcn = dividerand; % Divide data randomlynet.divideMode = sample; % Divide up every samplenet.divideParam.trainRatio = 90/100;net.divideParam.valRatio = 5/100;net.divideParam.testRatio = 5/100;% Choose a Performance Function% For a list of all perf

40、ormance functions type: help nnperformancenet.performFcn = mse; % Mean squared error% Choose Plot Functions% For a list of all plot functions type: help nnplotnet.plotFcns = plotperform,plottrainstate,ploterrhist, . plotregression, plotfit;% Train the Networknet,tr = train(net,x,t);% Test the Networ

41、ky = net(x);e = gsubtract(t,y);performance = perform(net,t,y)% Recalculate Training, Validation and Test PerformancetrainTargets = t .* tr.trainMask1;valTargets = t .* tr.valMask1;testTargets = t .* tr.testMask1;trainPerformance = perform(net,trainTargets,y)valPerformance = perform(net,valTargets,y)

42、testPerformance = perform(net,testTargets,y)% View the Networkview(net)% Plots% Uncomment these lines to enable various plots.%figure, plotperform(tr)%figure, plottrainstate(tr)%figure, plotfit(net,x,t)%figure, plotregression(t,y)%figure, ploterrhist(e)% Deployment% Change the (false) values to (tru

43、e) to enable the following code blocks.if (false) % Generate MATLAB function for neural network for application deployment % in MATLAB scripts or with MATLAB Compiler and Builder tools, or simply % to examine the calculations your trained neural network performs. genFunction(net,myNeuralNetworkFunct

44、ion); y = myNeuralNetworkFunction(x);endif (false) % Generate a matrix-only MATLAB function for neural network code % generation with MATLAB Coder tools. genFunction(net,myNeuralNetworkFunction,MatrixOnly,yes); y = myNeuralNetworkFunction(x);endif (false) % Generate a Simulink diagram for simulation

45、 or deployment with. % Simulink Coder tools. gensim(net);end6.2网络训练过程网络训练为:图9 第一代幼虫高峰期网络训练过程6.3训练结果训练结果为:图10 第一代幼虫高峰期网络训练结果训练样本、验证样本、测试样本的R值分别为0.875337、-1和1。误差直方图为:图11 第一代幼虫高峰期网络训练结果误差直方图训练样本、验证样本、测试样本、所有数据回归图为:图12 第一代幼虫高峰期网络训练结果回归图验证样本和测试样本R值均为1。7.第二代幼虫高峰期建模试验7.1程序代码程序代码(Simple Script)为:% Solve an Input-Output Fitting problem with a Neural Network% Script generated by Neural Fitting app% Created Wed Oct 28 20:22:04 CST 2015% This script assumes these variables are defined:% t2x - input data.% t2y - target data.x = t2x;t = t2y;% Choose a Tr

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 小学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁