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.
Question
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)
Expert Answer
Neeta Dsouza
PhD Expert
Answered Aug 13, 2026
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related deep learning Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →