Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to correctly export a TD3 model #1766

Closed
4 tasks done
Hurdle97 opened this issue Nov 25, 2023 · 5 comments
Closed
4 tasks done

[Question] How to correctly export a TD3 model #1766

Hurdle97 opened this issue Nov 25, 2023 · 5 comments
Labels
question Further information is requested

Comments

@Hurdle97
Copy link

Hurdle97 commented Nov 25, 2023

❓ Question

First of all, thank you very much for the very well-implemented library. I have an already trained TD3 model that I need to export in C. Basically I want to put the model into a controller that, given the observations, gives me the correct action to take. My idea is to export the SB3 model to Pycharm and then, using MATLAB, to C. The point is that I am not able to export it into Pycharm. My model uses the following net_arch = [1000, 500, 400, 300]. I searched in previous discussions and I found some material related to the old PPO2 algorithm only where action_probability(obs) was still present. Can you help me? Thank you in advance! :)

Checklist

@Hurdle97 Hurdle97 added the question Further information is requested label Nov 25, 2023
@Hurdle97 Hurdle97 changed the title [Question] How to correctly export a TD3 model [Question] [custom gym env] How to correctly export a TD3 model Nov 25, 2023
@Hurdle97 Hurdle97 changed the title [Question] [custom gym env] How to correctly export a TD3 model [Question] How to correctly export a TD3 model Nov 25, 2023
@araffin
Copy link
Member

araffin commented Nov 25, 2023

Hello,
have you read the "export model" section in the doc?

what do you mean by exporting to pycharm?

@Hurdle97
Copy link
Author

Hurdle97 commented Nov 25, 2023

Thanks for answering. Obviously I made a mistake, I meant PyTorch. Yes, I read the entire documentation #https://readthedocs.org/projects/stable-baselines/downloads/pdf/master/ but there is nothing related to the TD3.

@Hurdle97
Copy link
Author

To clarify, I know that I have to use get_parameters function to obtain model parameters and then construct the network
manually in PyTorch assignig the parameters correctly. I also read the old discussion hill-a/stable-baselines#372 where you implement the procedure for PPO2. I tried to reproduce it in order to fit TD3 but it doesn't work.

@araffin
Copy link
Member

araffin commented Nov 27, 2023

Yes, I read the entire documentation

This should be the relevant section for you: https://stable-baselines3.readthedocs.io/en/master/guide/export.html#export-to-onnx (SAC is very similar to TD3)

also relevant issue:
#1349 (comment)

onnx in matlab: https://de.mathworks.com/help/deeplearning/ref/importnetworkfromonnx.html

@Hurdle97
Copy link
Author

Thank you very much for answering. The links that you gave me were useful. Now I managed to export the model in MATLAB.

@araffin araffin closed this as completed Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants