how to import training weights from Python to Matlab?

6 次查看(过去 30 天)
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 个评论
Mudit Chaturvedi
Mudit Chaturvedi 2021-7-19
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 2021-7-19
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deep Learning with Simulink 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by