question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

save and load is different from save then load ??!!

See original GitHub issue

Hello 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

  1. snake_model.learn(total_timesteps=100000) snake_model.save('./snake_modeltest') snake_model2 = PPO2.load("./snake_modeltest")

  2. nake_model.learn(total_timesteps=100000) snake_model2 = PPO2.load("./snake_modeltest")

  3. 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:closed
  • Created 4 years ago
  • Comments:11

github_iconTop GitHub Comments

3reactions
Miffylicommented, Feb 28, 2020

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.

1reaction
zhaishengfucommented, Feb 28, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Semantic differences between save/write/store and read/load?
I use load / save for methods that implicitly know or infer where to get or put the data, whereas read and write...
Read more >
Load / Save definitions
Load definition imports a new resource into a project while Save definition saves it for export to another system. For example you may...
Read more >
Chapter 6 Loading and saving data | Introduction - Bookdown
In this chapter, we will further discuss loading and saving data. R can load many different data files, such as Excel files, CSV...
Read more >
An Incredibly Powerful & Flexible SAVE LOAD System
Every single game (almost) needs some sort of Save & Load system. This is definitely my favorite.There are so many ways to do...
Read more >
Save and Load - YouTube
Going through how to save and load files NOT using player prefs because we aren't trying to get our game data hacked here....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found