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>
This commit is contained in:
Paul Stahlhofen 2025-02-07 12:04:48 +01:00 committed by GitHub
parent b8b2d30a83
commit c5c29a32d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View file

@ -225,6 +225,26 @@ You can find below an example for extracting one key from the observation:
env = VecExtractDictObs(env, key="observation")
.. note::
When creating a vectorized environment, you can also specify ordinary gymnasium
wrappers to wrap each of the sub-environments. See the
:func:`make_vec_env <stable_baselines3.common.env_util.make_vec_env>`
documentation for details.
Example:
.. code-block:: python
from gymnasium.wrappers import RescaleAction
from stable_baselines3.common.env_util import make_vec_env
# Use gym wrapper for each sub-env of the VecEnv
wrapper_kwargs = dict(min_action=-1.0, max_action=1.0)
vec_env = make_vec_env(
"Pendulum-v1", n_envs=2, wrapper_class=RescaleAction, wrapper_kwargs=wrapper_kwargs
)
VecEnv
------

View file

@ -36,6 +36,7 @@ Others:
Documentation:
^^^^^^^^^^^^^^
- Clarify the use of Gym wrappers with ``make_vec_env`` in the section on Vectorized Environments (@pstahlhofen)
Release 2.5.0 (2025-01-27)
@ -1782,4 +1783,4 @@ And all the contributors:
@DavyMorgan @luizapozzobon @Bonifatius94 @theSquaredError @harveybellini @DavyMorgan @FieteO @jonasreiher @npit @WeberSamuel @troiganto
@lutogniew @lbergmann1 @lukashass @BertrandDecoster @pseudo-rnd-thoughts @stefanbschneider @kyle-he @PatrickHelm @corentinlger
@marekm4 @stagoverflow @rushitnshah @markscsmith @NickLucche @cschindlbeck @peteole @jak3122 @will-maclean
@brn-dev @jmacglashan @kplers @MarcDcls @chrisgao99
@brn-dev @jmacglashan @kplers @MarcDcls @chrisgao99 @pstahlhofen