Azzera filtri
Azzera filtri

How to use multiple data in LSTM?

26 visualizzazioni (ultimi 30 giorni)
daemo Lee
daemo Lee il 12 Gen 2022
Commentato: Pratyush Roy il 19 Gen 2022
  1. Discription said that is 'For single time step predictions, use the CPU.' I wonder how to do multi time step pridiction in Matlab.
  2. Espacially, I would like to know about the way to use multi training data set for LSTM, not single training data set like this example.
That example used a double data(1xN), but I hope to enter multiple(M) double data(like MxN).
Please let me know some idea or give your knowledge.

Risposta accettata

Pratyush Roy
Pratyush Roy il 17 Gen 2022
Hi Daerno.
The example mentioned in the question is used for finding temporal relation between 1-D input and 1 dimensional output. As mentioned in the code:
numFeatures = 1;
numResponses = 1;
numHiddenUnits = 200;
layers = [ ...
sequenceInputLayer(numFeatures)
lstmLayer(numHiddenUnits)
fullyConnectedLayer(numResponses)
regressionLayer];
The number of features is 1. Hence the data passed as input is 1-dimensional in nature.
In general, LSTMs are built to work for multi-dimensional data. We can change the numFeatures and numResponses value to map one single/multi-dimensional vector to another single/multi-dimensional vector. This doc link captures a example involving multi-dimensional vectors.
Hope this helps!
  2 Commenti
daemo Lee
daemo Lee il 18 Gen 2022
First of all, thank you for helping me.
Unfortunately, my fundamental problem is I would like to use a dataset for just about one feature(numFeatures=1).
For example, if I want to predict the price of stock I could train the model through the below code
and assume X is the only feature like the price of the stock for 1~9 timestep(month) and Y is the price of the stock for 2~10 timestep(month).
XTrain = [1,2,3,4,5,6,7,8,9]
YTrain = [2,3,4,5,6,7,8,9,10]
[net,info] = trainNetwork(XTrain,YTrain,layers,options);
but I hope to know how to train multi-data sets (3 stock data & numFeatures=1) simultaneously when I take multi same feature like below.
XTrain1 = [1,2,3,4,5,6,7,8,9]
YTrain1 = [2,3,4,5,6,7,8,9,10]
XTrain2 = [2,2,4,5,6,8,10,11,12]
YTrain2 = [2,4,5,6,8,10,11,12,15]
XTrain3 = [5,3,2,1,1,1,6,9,10]
YTrain3 = [3,2,1,1,1,6,9,10,15]
[net,info] = trainNetwork(XTrain,YTrain,layers,options);
Please reply.
Pratyush Roy
Pratyush Roy il 19 Gen 2022
Hi Daemo,
Since you have multiple datasets, you can train multiple LSTMs in parallel. Please refer to the doc link below for more details:
Hope this helps!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Sequence and Numeric Feature Data Workflows in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by