Import Keras network From Python to Matlab

Hi,
I want to import a trained TensorFlow Keras model from Python to Matlab. I already have a '.h5' file with this model, but I keep getting the error 'Keras network with multiple inputs or multiple outputs is not supported when one of the network inputs is sequential' when I use the function ImportKerasNetwork or ImportKerasLayers.
Is there any way in solving this? Or is there any other way to import this model into Matlab?

답변 (1개)

Sivylla Paraskevopoulou
Sivylla Paraskevopoulou 2022년 11월 15일

0 개 추천

You can try to import your TensorFlow model by using the importTensorFlowNetwork function, which is a newer function than importKerasNetwork and supports more options.
You have to save your .h5 model in the SavedModel format to import it by using the importTensorFlowNetwork function.

댓글 수: 6

Hi, I have tried this but this gives me the same error again. I think i have to convert the model to a Functional model to make it work
The importTensorFlowNetwork function can import TensorFlow networks created with the sequential or functional API, but not models with subclassing.
I am using a sequential LSTM network so this shoud not be a problem i guess?
The function supports importing LSTM networks. This does not necessarily mean that it supports all the layers in your TensorFlow model for conversion to MATLAB layers. To learn more, read these sections on Autogenerated Custom Layers and Placeholder Layers.
It seems that my network is bit too complicated to insert into Matlab. I will connect Matlab with Python and call the Python script from Matlab to run this model. This will be the easiest solution. Thank you for the support!
Sivylla Paraskevopoulou
Sivylla Paraskevopoulou 2022년 11월 18일
편집: Sivylla Paraskevopoulou 2022년 11월 18일
You are welcome! For this workflow, you might find this GitHub example helpful: Image Classification in MATLAB Using TensorFlow.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 11월 13일

편집:

2022년 11월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by