Skip to content

Commit c5c29a3

Browse files
pstahlhofenaraffin
andauthoredFeb 7, 2025··
Clarify the use of Gym wrappers with make_vec_env (#2079)
* Added a note to the documentation of Vectorized Environments to show the possibility of wrapping sub-environments with `make_vec_env` (See #2075 ) * Add example --------- Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
1 parent b8b2d30 commit c5c29a3

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed
 

‎docs/guide/vec_envs.rst

+20
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,26 @@ You can find below an example for extracting one key from the observation:
225225
env = VecExtractDictObs(env, key="observation")
226226
227227
228+
.. note::
229+
When creating a vectorized environment, you can also specify ordinary gymnasium
230+
wrappers to wrap each of the sub-environments. See the
231+
:func:`make_vec_env <stable_baselines3.common.env_util.make_vec_env>`
232+
documentation for details.
233+
Example:
234+
235+
.. code-block:: python
236+
237+
from gymnasium.wrappers import RescaleAction
238+
from stable_baselines3.common.env_util import make_vec_env
239+
240+
# Use gym wrapper for each sub-env of the VecEnv
241+
wrapper_kwargs = dict(min_action=-1.0, max_action=1.0)
242+
vec_env = make_vec_env(
243+
"Pendulum-v1", n_envs=2, wrapper_class=RescaleAction, wrapper_kwargs=wrapper_kwargs
244+
)
245+
246+
247+
228248
VecEnv
229249
------
230250

‎docs/misc/changelog.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Others:
3636

3737
Documentation:
3838
^^^^^^^^^^^^^^
39+
- Clarify the use of Gym wrappers with ``make_vec_env`` in the section on Vectorized Environments (@pstahlhofen)
3940

4041

4142
Release 2.5.0 (2025-01-27)
@@ -1782,4 +1783,4 @@ And all the contributors:
17821783
@DavyMorgan @luizapozzobon @Bonifatius94 @theSquaredError @harveybellini @DavyMorgan @FieteO @jonasreiher @npit @WeberSamuel @troiganto
17831784
@lutogniew @lbergmann1 @lukashass @BertrandDecoster @pseudo-rnd-thoughts @stefanbschneider @kyle-he @PatrickHelm @corentinlger
17841785
@marekm4 @stagoverflow @rushitnshah @markscsmith @NickLucche @cschindlbeck @peteole @jak3122 @will-maclean
1785-
@brn-dev @jmacglashan @kplers @MarcDcls @chrisgao99
1786+
@brn-dev @jmacglashan @kplers @MarcDcls @chrisgao99 @pstahlhofen

0 commit comments

Comments
 (0)
Please sign in to comment.