MATLAB Answers

Error: Importing Keras networks with more than 1 input or output layer is not yet supported.

6 views (last 30 days)
Xu Fei
Xu Fei on 24 Mar 2020
I am using matlab 2019b.
I was going to import a pretrained Keras-tensorflow network in matlab, so I downloaded the latest version of "Deep Learning Toolbox Importer for TensorFlow-Keras Models" (available here:
I used the following command:
modelfile = 's2_038_model.json';
weights = 's2_038_lr_1e-04.h5';
net = importKerasNetwork(modelfile,'WeightFile',weights,'OutputLayerType','regression')
However I got this error: "Importing Keras networks with more than 1 input or output layer is not yet supported."
I notice that the latest version of this tool box already allows to import multiple inputs/outputs network, but how does this error happen?
Anyone has the same problem as mine?
Wish online friends could help me with some solutions, thanks in advance!

Answers (1)

Sivylla Paraskevopoulou
Sivylla Paraskevopoulou on 12 Feb 2021
Edited: Sivylla Paraskevopoulou on 12 Feb 2021
Since R2020a, you can import a Keras network with multiple inputs and multiple outputs. Try downloading a R2020a version or later of the support package. Use importKerasNetwork if the network includes input size information for the inputs and loss information for the outputs. Otherwise, use importKerasLayers. The importKerasLayers function inserts placeholder layers for the inputs and outputs. After importing, you can find and replace the placeholder layers by using findPlaceholderLayers and replaceLayer respectively.

Community Treasure Hunt

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

Start Hunting!