How to connect a 1d convolution layer after a LSTM layer with output mode "last"?

4 ビュー (過去 30 日間)
Yufan
Yufan 2024 年 4 月 7 日
コメント済み: Manikanta Aditya 2024 年 4 月 8 日
I am working on classify sEMG data, and I want to build a LSTM-CNN network. I want to first employ a LSTM layer and take the last output as the input of a 1D convolution layer.
layers = [ ...
sequenceInputLayer(sEMG_channels)
lstmLayer(numHiddenUnits,'OutputMode','sequence')
lstmLayer(numHiddenUnits,'OutputMode','last')
convolution1dLayer(3,25,'Padding','same')
batchNormalizationLayer
reluLayer
dropoutLayer(0.4)
convolution1dLayer(3,10,'Padding','same')
batchNormalizationLayer
reluLayer
fullyConnectedLayer(23)
softmaxLayer
classificationLayer];
However, when I run it. It returns that the convolution1dLayer has 0 temporal dimension and 0 spatial dimension.
my input data XTrain is a 1000*1 cell and in each cell is a 48*30000 double matrix which means that my sEMG data has 48 channels and 30000 time points.
What is the output of lstmLayer(numHiddenUnits,'OutputMode','last') like?
how can i connect LSTM with CNN?
  3 件のコメント
Yufan
Yufan 2024 年 4 月 8 日
編集済み: Yufan 2024 年 4 月 8 日
Thank you for answer my question!
But adding
reshape([1, 1, numHiddenUnits])
Error using reshape
Not enough input arguments.
does not work! There is not enough input arguments.
how can i convey the output of LSTM layer into the reshape layer?
I want to conduct a network like this.
Manikanta Aditya
Manikanta Aditya 2024 年 4 月 8 日
layers = [ ...
sequenceInputLayer(48) % Assuming sEMG_channels = 48
lstmLayer(numHiddenUnits, 'OutputMode', 'last')
reshapeLayer([1 1 numHiddenUnits],'Name','reshape') % Reshape LSTM output to have a spatial dimension
convolution1dLayer(3, 25, 'Padding', 'same')
batchNormalizationLayer
reluLayer
dropoutLayer(0.4)
convolution1dLayer(3, 10, 'Padding', 'same')
batchNormalizationLayer
reluLayer
fullyConnectedLayer(23)
softmaxLayer
classificationLayer];

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeAI for Signals についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by