Import Keras Tensorflow Model into Simulink
28 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lucas Ferreira-Correia
el 11 de Sept. de 2020
Comentada: Jie Li
el 13 de Oct. de 2021
I'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
0 comentarios
Respuesta aceptada
sruthi gundeti
el 12 de Sept. de 2020
Hi,
You can import your keras network using
net = importKerasNetwork(modelfile)
net = importKerasNetwork(modelfile,Name,Value)
model file can .h5 format ot json format with weights
Then write a entry level function for the imported network
function out = resnetFun(in)
persistent mynet;
if isempty(mynet)
mynet = coder.loadDeepLearningNetwork('resnet50', 'myresnet');
end
out = predict(mynet,in);
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.
2 comentarios
sruthi gundeti
el 7 de Jun. de 2021
VxNet=importKerasNetwork('Network.json','WeightFile','Network.h5','OutputLayerType','regression')
This can import a regression network
Más respuestas (1)
Fernando Liozzi
el 5 de Jun. de 2021
Hi,
Is it possible to use this method to generate code for a microcontroller in c / c ++? Thank you.
2 comentarios
Fernando Liozzi
el 5 de Jun. de 2021
Thanks, yes, is possible, my keras NN is working perfectly in a STM32!
Jie Li
el 13 de Oct. de 2021
Hi, Fernando, Could you post how you put it in the simulink? My code says the importKerasNetwork cannot be used when complie.Thanks
Ver también
Categorías
Más información sobre CPU Code Generation from MATLAB Applications en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!