How Can I Apply multiple inputs to get a output with LSTM
25 views (last 30 days)
Show older comments
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;)
0 Comments
Answers (2)
Marcelo Olmedo
on 6 May 2020
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 Comments
Mohamed Nedal
on 3 Jul 2020
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
on 10 May 2021
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
on 5 Jan 2021
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?
0 Comments
See Also
Categories
Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!