You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ADV_STABLE_BASELINES_3.md
+50-26Lines changed: 50 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,42 +46,66 @@ While the default options for sb3 work reasonably well. You may be interested in
46
46
47
47
We recommend taking the [sb3 example](https://github.com/edbeeching/godot_rl_agents/blob/main/examples/stable_baselines3_example.py) and modifying to match your needs.
48
48
49
-
This example exposes more parameter for the user to configure, such as `--speedup` to run the environment faster than realtime and the `--n_parallel` to launch several instances of the game executable in order to accelerate training (not available for in-editor training).
49
+
The example exposes more parameters for the user to configure, such as `--speedup` to run the environment faster than realtime and the `--n_parallel` to launch several instances of the game executable in order to accelerate training (not available for in-editor training).
50
50
51
+
To use the example script, first move to the location where the downloaded script is in the console/terminal, and then try some of the example use cases below:
51
52
52
-
```python
53
-
import argparse
54
-
55
-
from godot_rl.wrappers.stable_baselines_wrapper import StableBaselinesGodotEnv
parser.add_argument("--speedup", default=1, type=int, help="whether to speed up the physics in the env")
73
-
parser.add_argument("--n_parallel", default=1, type=int, help="whether to speed up the physics in the env")
75
+
### Set an experiment directory and name:
76
+
You can optionally set an experiment directory and name to override the default. When saving checkpoints, you need to use a unique directory or name for each run (more about that below).
### Train a model for 10_000 steps then save and export the model
82
+
The exported .onnx model can be used by the Godot sync node to run inference from Godot directly, while the saved .zip model can be used to resume training later or run inference from the example script by adding `--inference`.
This will load the previously saved model.zip, and resume training for another 100 000 steps, so the saved model will have been trained for 200 000 steps in total.
89
+
Note that the console log will display the `total_timesteps` for the last training session only, so it will show `100000` instead of `200000`.
You can save periodic checkpoints and later resume training from any checkpoint using the same CL argument as above, or run inference on any checkpoint just like with the saved model.
96
+
Note that you need to use a unique `experiment_name` or `experiment_dir` for each run so that checkpoints from one run won't overwrite checkpoints from another run.
97
+
Alternatively, you can remove the folder containing checkpoints from a previous run if you don't need them anymore.
79
98
80
-
model = PPO("MultiInputPolicy", env, ent_coef=0.0001, verbose=2, n_steps=32, tensorboard_log="logs/sb3")
81
-
model.learn(200000)
99
+
E.g. train for a total of 2 000 000 steps with checkpoints saved at every 50 000 steps:
Checkpoints will be saved to `logs\sb3\experiment1_checkpoints` in the above case, the location is affected by `--experiment_dir` and `--experiment_name`.
86
106
87
-
```
107
+
### Run inference on a saved model for 100_000 steps
108
+
You can run inference on a model that was previously saved using either `--save_model_path` or `--save_checkpoint_frequency`.
0 commit comments