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);
總結
以上是生活随笔為你收集整理的matlab narxnet,请问吧里有大神做过MATLAB时间序列神经网络(NARX)吗?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 位置传感器matlab,永磁同步电机无位
- 下一篇: php正则表达式正向预查,javascr