How Can I Apply multiple inputs to get a output with LSTM

조회 수: 55 (최근 30일)
Shuhei IKEDA
Shuhei IKEDA 2019년 11월 3일
댓글: Song Decn 2021년 5월 10일
Hi there,
I would like to build a LSTM regression network,
I have 5 inuts data under common time series steps, and corresponding train-output data as well.
Tried to train the network with 6 data avobe.(I combined 5 input data into a cell array data to apply the network), but I got an error 'Invalid training data. Sequence responses must have the same sequence length as the corresponding predictors.'
I really appreciate if someone respon me. Thank you;)

답변 (2개)

Marcelo Olmedo
Marcelo Olmedo 2020년 5월 6일
Hello! The key is in the data entry. I leave you an example importing training data of 5 input variables and one output. Then the test is done and finally it is graphed. The example is very basic but it will give you a good idea of ​​the procedure
  댓글 수: 2
Mohamed Nedal
Mohamed Nedal 2020년 7월 3일
Hi @Marcelo,
I tried to add a few lines of code to predict new future values of the target output, here's what I added:
%% Forecast the Future
net = resetState(net);
Yforecast = [];
numTimeStepsTest = numel(XTest) + 500; % to forecast new 500 steps in the future
for i = 1:numTimeStepsTest
[net, Yforecast(:,i)] = predictAndUpdateState(net, XTest(:,i), 'ExecutionEnvironment','cpu');
end
but I got this error:
Conversion to double from cell is not possible.
Error in LSTM_multi_motores (line 82)
[net, Yforecast(:,i)] = predictAndUpdateState(net, XTest(:,i),
'ExecutionEnvironment','cpu');
Can you please tell me how to fix this part?
Song Decn
Song Decn 2021년 5월 10일
hi Marcelo, thank you for your reference code. I tried with predictAndUpdateState(), this function delivers a different response as predict. Do you know perhaps why?
% opt1: pure use feature variables as input
net = resetState(net);
YPred = [];
for i = 1:numel(XTest)
[net, temp] = predictAndUpdateState(net, XTest(:,i), 'ExecutionEnvironment', 'cpu');
YPred(:,i) = cell2mat(temp);
end
y1 = YPred;
% opt2: 用 predict() 函数
net = resetState(net);
YPred = predict(net, XTest);
y2 = (cell2mat(YPred)); %have to transpose as plot plots columns

댓글을 달려면 로그인하십시오.


Hira Majeed
Hira Majeed 2021년 1월 5일
Hi @Marcelo,
I have a similar problem, but my data has an input with 2 features each where each feature has 29 length, so I am arranging it into a cell which is 90,000x1, and each cell has 2x29 double. now my labels are 90,000x1 and each cell is 1x1. but it says dimensions do not match, do you have any opinion abotu how to solve this?

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by