NARX神经网络多步和单步预测

上传人:ni****g 文档编号:549022546 上传时间:2023-07-10 格式:DOC 页数:18 大小:276KB
返回 下载 相关 举报
NARX神经网络多步和单步预测_第1页
第1页 / 共18页
NARX神经网络多步和单步预测_第2页
第2页 / 共18页
NARX神经网络多步和单步预测_第3页
第3页 / 共18页
NARX神经网络多步和单步预测_第4页
第4页 / 共18页
NARX神经网络多步和单步预测_第5页
第5页 / 共18页
点击查看更多>>
资源描述

《NARX神经网络多步和单步预测》由会员分享,可在线阅读,更多相关《NARX神经网络多步和单步预测(18页珍藏版)》请在金锄头文库上搜索。

1、% Solve an Autoregression Problem with External Input with a NARX NeuralNetwork 解决一个 NARX 神经网络的外部输入自回归问题% Script generated by Neural Time Series app脚本由神经时间序列程序生成% Created 28-Mar-2017 10:42:15% This script assumes these variables are defined:此脚本假设以下变量已定义:% in - input time series.in-输入时间序列% out - feed

2、back time series.out-反馈时间序列%tonndata/fromnndata 把数据转化为标准神经网络格式X = tonndata(in,false,false);T = tonndata(out,false,false);% 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

3、problems.% trainscg uses less memory. Suitable in low memory situations. trainFcn = trainlm ; % Levenberg-Marquardt backpropagation.% Create a Nonlinear Autoregressive Network with External Input inputDelays = 1:2;feedbackDelays = 1:2; hiddenLayerSize = 10;net =选择输入和反馈前 / 删除矩阵的行定值。删除矩阵的行定mapminmax ;

4、mapminmax ;narxnet(inputDelays,feedbackDelays,hiddenLayerSize, open ,trainFcn);% Choose Input and Feedback Pre/Post-Processing Functions 后处理功能% Settings for feedback input are automatically applied to feedback output 反馈输入的设置将自动应用于反馈输出% For a list of all processing functions type: help nnprocess% Cus

5、tomize input parameters at: net.inputsi.processParam 映射矩阵行的最小值和最大值为 1 - 1 % Customize output parameters at: net.outputsi.processParam 值。映射矩阵行的最小值和最大值为 1 - 1 net.inputs1.processFcns = removeconstantrowsnet.inputs2.processFcns = removeconstantrows% Prepare the Data for Training and Simulation准备数据用于训练和

6、模拟% The function PREPARETS prepares timeseries data for a particular network, preparets 功能,为一个特定的网络准备时间序列数据,% shifting time by the minimum amount to fill input states and layer% states. Using PREPARETS allows you to keep your original time series data% unchanged, while easily customizing it for netw

7、orks with differing% numbers of delays, with open loop or closed loop feedback modes. 移动时间的最小量从而填写输入状态和层的状态。使用 PREPARETS 使你可以保存原时间序列数据不变,同时更易定制不同的网络延迟,通过开环或闭环反馈模式。x,xi,ai,t = preparets(net,X,T);数据分割用于训练,% Setup Division of Data for Training, Validation, Testing 验证,测试% For a list of all data division

8、 functions type: help nndividenet.divideFcn = dividerand net.divideMode = time ; net.divideParam.trainRatio = 70/100; net.divideParam.valRatio = 15/100; net.divideParam.testRatio = 15/100; % Divide data randomly % Divide up every sample% Choose a Performance Function选择性能函数% For a list of all perform

9、ance functions type: help nnperformance net.performFcn =mse ; % Mean Squared Error均方误差% Choose Plot Functions选择绘图功能ploterrhist% For a list of all plot functions type: help nnplot net.plotFcns = plotperform , plottrainstateplotregressionplotresponse , ploterrcorrplotinerrcorr ;% Train the Network训练网络

10、net,tr = train(net,x,t,xi,ai);% Test the Network测试网络y = net(x,xi,ai);e = gsubtract(t,y); performance = perform(net,t,y)% Recalculate Training, Validation and Test Performance重新训练,验证和测试性能trainTargets = gmultiply(t,tr.trainMask);valTargets = gmultiply(t,tr.valMask); testTargets = gmultiply(t,tr.testMa

11、sk); trainPerformance = perform(net,trainTargets,y) valPerformance = perform(net,valTargets,y) testPerformance = perform(net,testTargets,y)% View the Network查看网络view(net)% Plots% Uncomment these lines to enable various plots.%figure, plotperform(tr)%figure, plottrainstate(tr)%figure, ploterrhist(e)%

12、figure, plotregression(t,y)%figure, plotresponse(t,y)%figure, ploterrcorr(e)%figure, plotinerrcorr(x,e)% Closed Loop Network闭环网络% Use this network to do multi-step prediction. 利用此网络进行多步预测。% The function CLOSELOOP replaces the feedback input with a direct% connection from the outout layer.函数 CLOSELOO

13、P 使用一个输出层的直接连接代替反馈输入。netc = closeloop(net);netc.name = net.name - Closed Loop;view(netc)xc,xic,aic,tc = preparets(netc,X,T); yc = netc(xc,xic,aic);closedLoopPerformance = perform(net,tc,yc) % Multi-step Prediction 多步预测% Sometimes it is useful to simulate a network in open-loop form for as% long as t

14、here is known output data, and then switch to closed-loop form% to perform multistep prediction while providing only the external input.% Here all but 5 timesteps of the input series and target series are used% to simulate the network in open-loop form, taking advantage of the higher % accuracy that

15、 providing the target series produces: 有时以开环形式模拟网络只要有已知的输出数据,然后切换到闭环形式仅提供外部输入时执行多步 预测。 这里只有 5步的输入序列和目标序列的方法用开环形式模拟网络,利用较高的提供目标系列的精度numTimesteps = size(x,2); knownOutputTimesteps = 1:(numTimesteps-5);predictOutputTimesteps = (numTimesteps-4):numTimesteps;X1 = X(:,knownOutputTimesteps);T1 = T(:,knownOutputTimesteps); x1,xio,aio = preparets(net,X1,T1);y1,xfo,afo = net(x1,xio,aio);% Next the the network and its final states will be converted to % closed-loop form to make five predictions with only the

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号