save and load is different from save then load ??!!
See original GitHub issueHello I met one really strange problem. I write one snake environment as custom enrivonment https://github.com/pedrohbtp/snake-rl and using PPO2 to train it . the problem is, when i save model and load at the same time, this is correct. but when i save the model first and then load the model, it is wrong, I have tested many days and the situation is
-
snake_model.learn(total_timesteps=100000)
snake_model.save('./snake_modeltest')
snake_model2 = PPO2.load("./snake_modeltest")
-
nake_model.learn(total_timesteps=100000)
snake_model2 = PPO2.load("./snake_modeltest")
-
snake_model2 = PPO2.load("./snake_modeltest")
only the first situation will succeed. If I save it and then load it , it will fail. In other words, I must train, save and load at the same will the load function succeed. I used set_env and other functions so this is
not the problem.
And I tested another simple question, then it succeed no matter which situation !! So I guess this is the problem of your save and load. Maybe some situation will not work??
Issue Analytics
- State:
- Created 4 years ago
- Comments:11
Top GitHub Comments
Issue lies in the environment code, specifically line 85. The observation vector is put into a dictionary (not sure why), and then iterated over. Order of items is not guaranteed in a dictionary, which is why at different runs you get different results: the observation vector is different!
Try removing the use of dictionary at that point, or if you really have to use a dictionary, use
collections.OrderedDict
.If the environment then works fine, you can close this issue.
@Miffyli @araffin Yes, you are right!!! I used collections.OrderedDict and Now I can load it correctly and the render result is also wonderful! Thank you very much 👍
Besides, I used official openai baseline, I do not know why but it is much slower than stable baseline with the same algorithm, and your library is easy to use. You really offered a wonderful library, Thanks again. I will close this issue.