eroor in lstm training network

4 vues (au cours des 30 derniers jours)
bhanu kiran vandrangi
bhanu kiran vandrangi le 25 Mar 2022
Commenté : KSSV le 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

Réponses (1)

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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by