dhyeythumar / PPO-algo-with-custom-Unity-environment

Implementation of Proximal Policy Optimization algorithm on a custom Unity environment.
https://medium.com/analytics-vidhya/ppo-algorithm-with-custom-rl-environment-made-with-unity-engine-effed6d98b9d
MIT License
17 stars 2 forks source link

How did you manage to save two models in to one (.ONNX) #6

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hi, i hope you are doing great. According to your PPO code, you are saving the models in two separate .hdf5 extensions after training is done. As far as I know, if we would like to use the Unity editor instead of the binary file (.exe), we should use only one training file with .ONNX extension. how did you turn the models into an ONNX extension file?

dhyeythumar commented 1 year ago

Hi @johnprada , Yes, .ONNX is a different type of format to freeze a trained model as compared to .hdf5.

If I remember correctly, at the time of developing this code TensorFlow didn't had great support to save models in .ONNX hence I used the .hdf5 format. And, yes .hdf5 format is not supported by the Unity engine if you want to use it inside the Unity editor.

That's why in my case, I wrote the test.py script for testing the .hdf5 model by directly using the .exe file.

You have 2 choices:

  1. Reimplement the model save feature to save the model in .ONNX format.
  2. Try using the ML-Agents trainer to train your RL agents.
ghost commented 1 year ago

Thanks for your answer @dhyeythumar