how to import training weights from Python to Matlab?

6 vues (au cours des 30 derniers jours)
Gülin Sayal
Gülin Sayal le 13 Juil 2021
Commenté : Gülin Sayal le 19 Juil 2021
Dear all,
I trained a reinforcement learning agent in Python using tensorflow 1.15 and saved the model in 3 files : save_net.ckpt.data-00000-of-00001
save_net.ckpt.index
save_net.ckpt.meta
The files, that I have saved through Python, are available in the attachment.
In Python I can simply load this model back, then input any observation set to get the action value that the trained agent chooses. However, I need to use Simulink for a closed loop simulation so I am trying to use these weight files in Matlab.
Do you have any suggestions about how I can use these three files in Matlab or Simulink in a way that I will input something and get the result for around 2000 time steps.
This is how I imagined in Simulink, the grey box needs to give actions by using the saved files and the input from the previous simulink block.
I would really appreciate any kind of help!
Best,
Gülin
  4 commentaires
Mudit Chaturvedi
Mudit Chaturvedi le 19 Juil 2021
Hello!
I understand you are trying to import training weights from Python to Matlab.
To my knowledge importing Tensorflow 1 weights directly into Matlab is not possible. You can convert the model from Tensorflow 1 to Tensorflow 2. (Refer to the limitations section in this link to know more about the exact versions of Tensorflow supported by the import function.) Tensorflow 2 weights can be imported into Matlab. Refer to this link to see how to do that.
Alternatively you can use importTensorFlowNetwork function however, this function is supported from R2021a onwards for TensorFlow 2.
Gülin Sayal
Gülin Sayal le 19 Juil 2021
Hi!
Thank you for the suggestions. I solved the problem by running the python code to select the actions over a matlab block in Simulink.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Deep Learning with Simulink dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by