eroor in lstm training network

1 view (last 30 days)
bhanu kiran vandrangi
bhanu kiran vandrangi on 25 Mar 2022
Commented: KSSV on 28 Mar 2022
'The training sequences are of feature dimension 1 but the input layer expects sequences of feature dimension 2.' this is the error i am getting whwn i run the code
clear all; clc;
Data=xlsread('EUR_USD Historical Data.csv')
Stock=Data(:,2)
percentage=Data(:,5)*100
[row col]=size(Data)
%create database for lstm
SequenceLength=30
Database={}
resultDatabase=[]
count=0
for i=row:-1:SequenceLength
count=count+1
a=Stock(i-SequenceLength+1:i)'
a=flip(a)
b=percentage(i-SequenceLength+1:i)'
b=flip(b)
Database{count,1}=[a,b]
end
[rt ct]=size(Database)
count=0
for i=1:rt-1
count=count+1
a=Database{count+1,1}
resultDatabase(count,1)=a(1,end)
end
EURUSDDatabase=Database
save EURUSDDatabase
%lstm creation
for i=1:rt-20
stockTrain{i,1}=Database{i,1}
end
restTrain=resultDatabase(1:rt-20)
numFeatures=2
numHiddenLayers=125
numResponses=1
Layers=[ sequenceInputLayer(numFeatures),...
lstmLayer(numHiddenLayers,'OutputMode','Last'),...
fullyConnectedLayer(numResponses),...
regressionLayer
]
miniBatchSize=3;
Epoch=20;
options=trainingOptions('adam',...
'ExecutionEnvironment','auto',...
'MaxEpochs',Epoch,...
'MiniBatchSize',miniBatchSize,...
'plots','training-progress')
TradernetEURUSD=trainNetwork(stockTrain,restTrain,Layers,options)
save TradernetEURUSD

Answers (1)

KSSV
KSSV on 25 Mar 2022
I think this line:
numFeatures=2
shoule be
numFeatures=1
  2 Comments
KSSV
KSSV on 28 Mar 2022
Feature is one.... Code runs but I suspect the data and the code.

Sign in to comment.

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!