eroor in lstm training network

1 次查看(过去 30 天)
bhanu kiran vandrangi
评论: KSSV 2022-3-28
'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

回答(1 个)

KSSV
KSSV 2022-3-25
I think this line:
numFeatures=2
shoule be
numFeatures=1
  2 个评论
bhanu kiran vandrangi
here i am taking two columns ,so the features should be 2 right?
KSSV
KSSV 2022-3-28
Feature is one.... Code runs but I suspect the data and the code.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by