Error in using LSTM for multipe responses

3 views (last 30 days)
clear all; clc;
Data=xlsread("C:\Users\vsvbh\OneDrive\Documents\LSTMPRBS.xlsx")
height1=Data(:,2)
height2=Data(:,3)
height3=Data(:,4)
flowrate1=Data(:,5)
flowrate2=Data(:,6)
[row col]=size(Data);
%create database for lstm
SequenceLength=1
Database={}
resultDatabase=[]
count=0
for i=row:-1:SequenceLength
count=count+1
a=height1(i-SequenceLength+1:i)';
a=flip(a);
b=height2(i-SequenceLength+1:i)';
b=flip(b);
c=height3(i-SequenceLength+1:i)';
c=flip(c);
d=flowrate1(i-SequenceLength+1:i)';
d=flip(d);
e=flowrate2(i-SequenceLength+1:i)';
e=flip(e);
Database{count,1}=[a;b;c;d;e];
end
[rt ct]=size(Database)
count=0
for i=1:rt-1
count=count+1
a=Database{count,1};
b=Database{count,1};
c=Database{count,1};
resultDatabase1(count,1)=a(1,end);
resultDatabase2(count,1)=b(2,end);
resultDatabase3(count,1)=c(3,end);
end
HeightDatabase=Database;
save HeightDatabase
%lstm creation
for i=1:rt-300
stockTrain{i,1}=Database{i,1}
end
restTrain1=resultDatabase1(1:rt-300)
restTrain2=resultDatabase2(1:rt-300)
restTrain3=resultDatabase3(1:rt-300)
restTrain={}
for i=1:700
restTrain{i,1}={restTrain1(i,:);restTrain2(i,:);restTrain3(i,:)}
end
numFeatures=5
numHiddenLayers1=100
numHiddenLayers2=100
numResponses=3
Layers=[ sequenceInputLayer(numFeatures),...
lstmLayer(numHiddenLayers1,'OutputMode','Last'),...
lstmLayer(numHiddenLayers2,'OutputMode','Last'),...
fullyConnectedLayer(numResponses),...
regressionLayer
]
miniBatchSize=20;
Epoch=200;
options=trainingOptions('adam',...
'ExecutionEnvironment','auto',...
'MaxEpochs',Epoch,...
'MiniBatchSize',miniBatchSize,...
'plots','training-progress')
Trainedheight=trainNetwork(stockTrain,restTrain,Layers,options)
save Trainedheight
i need to trian the data for three responses i have 1000 data points out of which i used 700 to train . so i need to train the data for all the three but it was giving a error

Answers (0)

Categories

Find more on Deep Learning with Time Series and Sequence Data in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!