matlab narxnet,请问吧里有大神做过MATLAB时间序列神经网络(NARX)吗?

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

请问吧里有大神做过MATLAB时间序列神经网络(NARX)吗?请教一下该神经网络的预测问题

我用网上的一个案例:知道2015年降雨我要预测该年水位。用往年的降雨与水位数据训练好网络后该怎么做预测。

代码如下;在这之后该怎么加载训练好的网络以及新的输入来预测输出呢?请高手解答一下,谢谢!

clear all

% Solve an Autoregression Problem with External Input with a NARX Neural Network

% Script generated by Neural Time Series app

% Created Thu Jun 08 14:20:08 CST 2017

%

% This script assumes these variables are defined:

%

% rain - input time series.

% water - feedback time series.

rawData=xlsread('R26-3.xlsx','sheet1','B2:D241');

rain=rawData(:,3);

water=rawData(:,2);

X = tonndata(rain,false,false);

T = tonndata(water,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 problems.

% 'trainscg' uses less memory. NTSTOOL falls back to this in low memory situations.

trainFcn = 'trainlm'; % Levenberg-Marquardt

% Create a Nonlinear Autoregressive Network with External Input

inputDelays = 1:4;

feedbackDelays = 1:4;

hiddenLayerSize = 10;

net = 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

% Customize input parameters at: net.inputs{i}.processParam

% Customize output parameters at: net.outputs{i}.processParam

net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};

net.inputs{2}.processFcns = {'removeconstantrows','mapminmax'};

% Prepare the Data for Training and Simulation

% The function PREPARETS prepares timeseries data for a particular network,

% 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 networks with differing numbers of delays, with

% open loop or closed loop feedback modes.

[x,xi,ai,t] = preparets(net,X,{},T);

% Setup Division of Data for Training, Validation, Testing

% The function DIVIDERAND randomly assigns target values to training,

% validation and test sets during training.

% For a list of all data division functions type: help nndivide

net.divideFcn = 'dividerand'; % Divide data randomly

% The property DIVIDEMODE set to TIMESTEP means that targets are divided

% into training, validation and test sets according to timesteps.

% For a list of data division modes type: help nntype_data_division_mode

net.divideMode = 'value'; % Divide up every value

net.divideParam.trainRatio = 70/100;

net.divideParam.valRatio = 15/100;

net.divideParam.testRatio = 15/100;

% Choose a Performance Function

% For a list of all performance functions type: help nnperformance

% Customize performance parameters at: net.performParam

net.performFcn = 'mse'; % Mean squared error

% Choose Plot Functions

% For a list of all plot functions type: help nnplot

% Customize plot parameters at: net.plotParam

net.plotFcns = {'plotperform','plottrainstate','plotresponse', ...

'ploterrcorr', 'plotinerrcorr'};

% Train the Network

[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);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值