Borrar filtros
Borrar filtros

LSTM training problem in MATLAB

2 visualizaciones (últimos 30 días)
Hossein Malekahmadi
Hossein Malekahmadi el 24 de Jul. de 2021
Comentada: Sruthi Gundeti el 26 de Jul. de 2021
Hi i tried to run LSTM with below code and i dont know why i get this error
close
clc
% Calculating amount of test data
N = round(size(inp_train,1)*30/100);%change 0.3 for defferent amount of test data
% Seperating data for training and testing
nn_train = inp_train(1:end-N,:);
in_test = inp_train(end+1-N:end,:);
tn_test = tar_train(end+1-N:end,:);
nn_target = tar_train(1:end-N,:);
numfeatures = size(nn_train,2);
numHiddenUnits = 100;
numClasses = size(nn_target,2);
layers = [...
sequenceInputLayer(numfeatures)
lstmLayer(numHiddenUnits)
fullyConnectedLayer(numClasses)
regressionLayer];
maxEpochs = 1000;
options = trainingOptions('adam',...
'MaxEpochs',maxEpochs,...
'InitialLearnRate',0.0001,...
'GradientThreshold', 0.01);
net = trainNetwork(nn_train, nn_target, layers, options);
the error:
Error using trainNetwork (line 150)
Invalid training data. Sequence responses must have the same sequence length as the corresponding
predictors.
Error in LSTM (line 30)
net = trainNetwork(nn_train, nn_target, layers, options);
and my data:

Respuesta aceptada

Sruthi Gundeti
Sruthi Gundeti el 26 de Jul. de 2021
Hi,
The LSTM network considers inputs as follows
No of rows= No of features
No of columns= No of Samples
No of samples for training data and target data must be same i.e., No of columns of NN_target and nn_train must be same
You can train by using transpose of both data
nn_train=nn_train'
nn_target=nn_target'
i.e.,net = trainNetwork(nn_train, nn_target, layers, options);
  2 comentarios
Hossein Malekahmadi
Hossein Malekahmadi el 26 de Jul. de 2021
Editada: Hossein Malekahmadi el 26 de Jul. de 2021
Thank you for your respond to my question when I checked the codes you mentioned I realised that I forget to transposing my data Again thank you very much Sruthi Gundeti
Sruthi Gundeti
Sruthi Gundeti el 26 de Jul. de 2021
You are welcome 🙂

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by