Input shape for the LSTM model

13 ビュー (過去 30 日間)
Yongho Son
Yongho Son 2021 年 7 月 28 日
回答済み: Prince Kumar 2021 年 9 月 7 日
Train dataset X has a shape of 1x50000 and each of 50000 elements has 5x1 data. Train dataset Y also has a shape of 1x50000 and each elements has 1x1 data. I wonder if the shape of the two datasets are valid to train lstm model like below because it keeps giving me an error msg " Invalid training data. Responses must be a matrix of numeric responses, or a N-by-1 cell array of sequences, where N is the number of sequences. The feature dimension of all sequences must be the same.
numFeatures = 5;
numHiddenUnits = 200;
numClasses = 1;
layers = [ ...
sequenceInputLayer(numFeatures)
lstmLayer(numHiddenUnits)
dropoutLayer(0.5)
fullyConnectedLayer(numClasses)
regressionLayer];
options = trainingOptions('adam', ...
'MaxEpochs',50, ...
'ValidationData',{test_x, test_y}, ...
'GradientThreshold',1, ...
'Verbose',1, ...
'Shuffle','never', ...
'ExecutionEnvironment','gpu', ...
'Plots','training-progress');
net = trainNetwork(train_x, train_y, layers, options);
Thank you for help in advance.
  1 件のコメント
KSSV
KSSV 2021 年 7 月 28 日
Check the given working examples in the doc and try to understand. Did you try to run given examples?

サインインしてコメントする。

回答 (1 件)

Prince Kumar
Prince Kumar 2021 年 9 月 7 日
Your train dataset X and Y should have dimension 50000x1.
Refer the example in this article. It has a sequence classification example.

カテゴリ

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