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

23 次查看(过去 30 天)
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