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)
Neeta Dsouza answered .
2025-11-20