How can i use sim function in trained neural network
이전 댓글 표시
i have input 7*2601 and target 1*2601 data. I trained Narx network and got the some plots. I want to do forecasting with new data so i created new matrix with 7*1 matrix and put some data. But when i call "pre = net(testdata')';" its always gives the same errors which are
"Error using network/sim (line 271) Number of inputs does not match net.numInputs.
Error in network/subsref (line 16) otherwise, v = sim(vin,subs{:});"
I read all of Narx , multistep predictions, open-close loop predictions but cant solve it. Any ideas ? Thank you.
code:
>>
Data = xlsread('data.xlsx'); Target = xlsread('Target.xlsx'); testdata= xlsread('testdata.xlsx'); X = tonndata(Data,false,false); T = tonndata(Target,false,false); trainFcn = 'trainlm';
inputDelays = 1:2; feedbackDelays = 1:2; hiddenLayerSize = 100; net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);
%net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'}; %net.inputs{2}.processFcns = {'removeconstantrows','mapminmax'};
[x,xi,ai,t] = preparets(net,X,{},T);
net.divideFcn = 'dividerand'; % Divide data randomly net.divideMode = 'time'; % Divide up every sample net.divideParam.trainRatio = 70/100; net.divideParam.valRatio = 15/100; net.divideParam.testRatio = 15/100;
net.performFcn = 'mse';
[net,tr] = train(net,x,t,xi,ai);
y = net(x,xi,ai); e = gsubtract(t,y); performance = perform(net,t,y);
trainTargets = gmultiply(t,tr.trainMask); valTargets = gmultiply(t,tr.valMask); testTargets = gmultiply(t,tr.testMask); trainPerformance = perform(net,trainTargets,y); valPerformance = perform(net,valTargets,y); testPerformance = perform(net,testTargets,y);
view(net)
pre = net(testdata')';
댓글 수: 1
Greg Heath
2015년 5월 24일
Run your code on one of the MATLAB Time-Series examples and we can compare results.
help nndatasets
doc nndatasets
load('simpleseries_dataset')%Simple time-series prediction dataset.
load('simplenarx_dataset')%Simple time-series prediction dataset.
load('exchanger_dataset')%Heat exchanger dataset.
load('maglev_dataset')%Magnetic levitation dataset.
load('ph_dataset')%Solution PH dataset.
load('pollution_dataset')%Pollution mortality dataset.
load('refmodel_dataset')%Reference model dataset
load('robotarm_dataset')%Robot arm dataset
load('valve_dataset')%Valve fluid flow dataset.
whos
So, which one do you want to pick?
Greg
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!