DLR-RM / rl-baselines3-zoo

A training framework for Stable Baselines3 reinforcement learning agents, with hyperparameter optimization and pre-trained agents included.
https://rl-baselines3-zoo.readthedocs.io
MIT License
1.9k stars 495 forks source link

Error when using recommended plotting commands #387

Open ikamensh opened 1 year ago

ikamensh commented 1 year ago

πŸ“š Documentation

I'm following instructions in https://stable-baselines3.readthedocs.io/en/master/modules/sac.html#how-to-replicate-the-results and get following error:

(sb3zoo) ~/o/rl-baselines3-zoo (master|✚2) [1] $ python scripts/plot_from_file.py -i logs/sac_results.pkl -latex -l SAC
# results_table
|Environments|    SAC    |
|------------|-----------|
|            |logs/      |
|HalfCheetah |9440 +/- 35|
|Ant         |0.0 +/- 0.0|
|Hopper      |0.0 +/- 0.0|
|Walker2D    |0.0 +/- 0.0|
keys: ['SAC-logs/']
2023-06-22 11:19:28.126 Python[74358:31690315] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/_p/sbw9kb5d3x1cv5jslnvbp6lm0000gp/T/org.python.python.savedState
Traceback (most recent call last):
  File "/Users/kai7rng/oss/rl-baselines3-zoo/scripts/plot_from_file.py", line 4, in <module>
    plot_from_file()
  File "/Users/kai7rng/oss/rl-baselines3-zoo/rl_zoo3/plots/plot_from_file.py", line 135, in plot_from_file
    timesteps = results[env][key]["timesteps"]
                ~~~~~~~~~~~~^^^^^
KeyError: 'SAC-logs/'

This might be because I copied previous command python scripts/all_plots.py -a sac -e HalfCheetah Ant Hopper Walker2D -f logs/ -o logs/sac_results and didn't remove environments I didn't run (e.g. Ant). Still error message could be more clear, or better empty folders could be skipped.

Thanks! :)

Checklist

araffin commented 1 year ago

Hello,

didn't remove environments I didn't run (e.g. Ant). Still error message could be more clear, or better empty folders could be skipped.

yes, that's probably the case, you should be able to re-run the previous command with only the correct env (it will overwrite the pkl file).

Still error message could be more clear, or better empty folders could be skipped.

I also agree and would welcome a PR that closes this issue =)

corentinlger commented 9 months ago

Hi, can I try to solve this ? Or someone is already doing it ?

araffin commented 9 months ago

Hi, can I try to solve this ?

yes you can =)