Question
Hi, I've imported a pre-trained network from tensorflow keras on MATLAB using importKerasLayers (importKerasNetwork didn't work as I've got 3 inputs). This network is made for sequence to sequence time series regression, hence I need a sequenceInputLayer in front of the network, however when I import the network an imageInputLayer is put in front of the network. Of course that layer is unsuitable for my use case, hence I tried replacing the imageInputLayer with a sequenceInputLayer but the error below is shown. The name of the imageInputLayer is 'lstm_10_input'. Error using nnet.internal.cnn.util.validateLayersForLayerGraph>iAssertUniqueAndNonEmptyLayerNames (line 45) Layer names in layer array must be nonempty. Error in nnet.internal.cnn.util.validateLayersForLayerGraph (line 33) iAssertUniqueAndNonEmptyLayerNames(larray, existingLayers); Error in nnet.cnn.LayerGraph>iValidateLayers (line 556) larray = nnet.internal.cnn.util.validateLayersForLayerGraph(larray, existingLayers); Error in nnet.cnn.LayerGraph/replaceLayer (line 420) larray = iValidateLayers(larray, existingLayers); Error in keras_import (line 8) lgraph = replaceLayer(lgraph,'lstm_10_input',inputLayer); My code is as follows: net = importKerasLayers('model.h5', 'ImportWeights', true); lgraph = layerGraph(net); inputLayer = sequenceInputLayer(3); lgraph = replaceLayer(lgraph,'lstm_10_input',inputLayer); %This is where the error occurs
Expert Answer
Prashant Kumar
PhD Expert
Answered Aug 24, 2026
From the error message it is evident that the inputLayer in your code must contain a valid name (any character array) so that it can be replaced with ‘lstm_10_input’ layer. Giving a name to inputLayer will clear out the error message.
inputLayer = sequenceInputLayer(3,'Name','sequence_10_input'); lgraph = replaceLayer(lgraph,'lstm_10_input',inputLayer);
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 →