各位前輩~~
我以ntstool產生一個narx的時間序列預測
但因每次執行,所產生的結果都不一樣
也不知道哪一個結果比較好
不知道大家在做類神經網路的時候都怎麼修改這樣的問題
我的想法是
先做一次執行,若預測值與目標值誤差太大,則繼續訓練
但不知道在narx這樣的時間序列預測要怎麼修改??
可否教我怎麼改
clear all
clc
rawInputData=xlsread('BundDaily.xlsx','sheet1','B2:AG30');
rawTargetData=xlsread('BundDaily.xlsx','sheet2','E2:E30');
% rawTargetData - feedback time series.
inputSeries = tonndata(rawInputData,false,false);
targetSeries = tonndata(rawTargetData,false,false);
% Create a Nonlinear Autoregressive Network with External Input
inputDelays = 1:2;
feedbackDelays = 1:2;
hiddenLayerSize = 10;
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize);
[inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,{},targetSeries);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 60/100;
net.divideParam.valRatio = 20/100;
net.divideParam.testRatio = 20/100;
% Train the Network
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
% Test the Network
outputs = net(inputs,inputStates,layerStates);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs);
% View the Network
view(net)
netc = closeloop(net);
netc.name = [net.name ' - Closed Loop'];
view(netc)
[xc,xic,aic,tc] = preparets(netc,inputSeries,{},targetSeries);
yc = netc(xc,xic,aic);
closedLoopPerformance = perform(netc,tc,yc)
%=============================
% figure(1)
% plot([cell2mat(yc)' cell2mat(tc)'])
% Early Prediction Network
% For some applications it helps to get the prediction a timestep early.
% The original network returns predicted y(t+1) at the same time it is given y(t+1).
% For some applications such as decision making, it would help to have predicted
% y(t+1) once y(t) is available, but before the actual y(t+1) occurs.
% The network can be made to return its output a timestep early by removing one delay
% so that its minimal tap delay is now 0 instead of 1. The new network returns the
% same outputs as the original network, but outputs are shifted left one timestep.
nets = removedelay(net);
nets.name = [net.name ' - Predict One Step Ahead'];
view(nets)
[xs,xis,ais,ts] = preparets(nets,inputSeries,{},targetSeries);
ys = nets(xs,xis,ais);
earlyPredictPerformance = perform(nets,ts,ys)
figure(1)
plot([cell2mat(ys)' cell2mat(ts)'])
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.124.90.158