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

51 ビュー (過去 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 Center および File ExchangeSequence 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