フィルターのクリア

Is it possible to implement a LSTM layer after a CNN layer?

7 ビュー (過去 30 日間)
Sofía
Sofía 2018 年 4 月 26 日
コメント済み: krishna Chauhan 2020 年 6 月 26 日
I'm trying to implement a CNN layer + a LSTM layer, but I have an error: "Network: Incompatible layer types". Is it not possible to implement this combination in MATLAB or am I just writing it not properly?
My code:
layers = [ ...
sequenceInputLayer(inputSize)
convolution2dLayer(3,8,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
lstmLayer(numHiddenUnits,'OutputMode','last')
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer
];
Error:
Error using trainNetwork (line 154)
Invalid network.
Caused by:
Network: Incompatible layer types. The network contains layer types not supported with recurrent layers.
Detected recurrent layers:
layer 6 (LSTM)
Detected incompatible layers:
layer 2 (Convolution)
layer 3 (Batch Normalization)
layer 5 (Max Pooling)
Layer 2: Input size mismatch. Size of input to this layer is different from the expected input size.
Inputs to this layer:
from layer 1 (output size 500)
  1 件のコメント
Jake
Jake 2018 年 10 月 9 日
I would like to do this as well.

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

採用された回答

Mona
Mona 2018 年 9 月 19 日
As far as I know, no, you can't combine the two. You can train a CNN independently on your training data, then use the learned features as an input to your LSTM. However, learning and updating CNN weights while training an LSTM is unfortunately not possible.
  1 件のコメント
krishna Chauhan
krishna Chauhan 2020 年 6 月 26 日
Maam can i store the weights after say a number of epochs of CNN and then use those weights as input to LSTM?

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

その他の回答 (4 件)

charu
charu 2018 年 7 月 9 日
use bilstmLayer layer instead of lstm layer as in example
inputSize = 12;
numHiddenUnits = 100;
numClasses = 9;
layers = [ ...
sequenceInputLayer(inputSize)
bilstmLayer(numHiddenUnits,'OutputMode','last')
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer]
  1 件のコメント
Guillaume  JUBIEN
Guillaume JUBIEN 2018 年 9 月 3 日
I have the same problem by using a bilstm Layer. The error message is :
if true
Error using trainNetwork (line 154)
Invalid network.
Error in test_spa_REG (line 168)
net = trainNetwork(XTR,TTR,Layers,options);
Caused by:
Network: Incompatible layer types. The network contains layer types not supported with recurrent layers.
Detected recurrent layers:
layer 9 (BiLSTM)
Detected incompatible layers:
layer 1 (Image Input)
layer 2 (Transposed Convolution)
layer 'temp1' (Convolution)
layer 5 (Average Pooling)
and 1 other layers.
Layer 10: Input size mismatch. Size of input to this layer is different from the expected input size.
Inputs to this layer:
from layer 9 (output size 20)
Is it possible to combine CNN with LSTM layer ?

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


Shounak Mitra
Shounak Mitra 2019 年 7 月 11 日
Hello Everyone,
As of 19a, MATLAB supports workflows containing both CNN and LSTM layers.
Please check the link that contains an example showing the CNN+LSTM workflow --> https://www.mathworks.com/help/deeplearning/examples/classify-videos-using-deep-learning.html
  2 件のコメント
Bhavna Rajasekaran
Bhavna Rajasekaran 2019 年 11 月 8 日
編集済み: Bhavna Rajasekaran 2019 年 11 月 8 日
Is it possible to implement LSTM regression on an image (N-by-M array) such that the output is also a 2-dimesional array? Which means that the Predictors are an N-by-M array of sequences?
suraj sahoo
suraj sahoo 2019 年 11 月 11 日
Is the CNN+lstm layer trainable?

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


sotiraw sotiroglou
sotiraw sotiroglou 2019 年 3 月 24 日
Matlab 2019a is out. And it claims it can do this cnn - rnn combination.
Could someone give us an example?

sotiraw sotiroglou
sotiraw sotiroglou 2019 年 3 月 24 日
Matlab 2019a is out there , and it claims it can do this rnn cnn combination.
I dont know the details, but i write this answer to encourage everyone with the same issue to search and maybe help with an example

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by