MATLAB: Import Keras Tensorflow Model into SimulinkdeepimportkeraslearningmachineMATLABsimulinktensorflowI've got a trained model from Python, which I need to run on Simulink for my application.Is it possible to import trained Tensorflow Keras models and implement them in Simulink?Cheers,Lucas Best AnswerHi,You can import your keras network using https://in.mathworks.com/help/deeplearning/ref/importkerasnetwork.html#d120e51332net = importKerasNetwork(modelfile)net = importKerasNetwork(modelfile,Name,Value)model file can .h5 format ot json format with weightsThen write a entry level function for the imported network https://in.mathworks.com/help/gpucoder/ref/coder.loaddeeplearningnetwork.html?s_tid=answers_rc2-1_p4_MLTfunction out = resnetFun(in)persistent mynet;if isempty(mynet) mynet = coder.loadDeepLearningNetwork('resnet50', 'myresnet');endout = predict(mynet,in);You can integrate MATLAB function into your Simulink model using the MATLAB Function Block.You can execute your MATLAB code from within the model to read the input data from your sensor and then pass this data into your Simulink block.Refer to this example on how to use a MATLAB function block in your model. Related QuestionTransfer learning layers in alexnet and googlenetHow to run keras models in matlabHow is the in-line googlenet or inception v3 created using codesBatch learning for deep learning lstm time seriesImplementing A Siamese Architecture With MatlabKeras TensorFlow importer: can’t upload weights from .h5 file using importKerasNetwork.
Best Answer