Description
Description
Problem:
Vectorized Gymnasium environments with discrete action spaces fail since SKRL passes actions with a wrong shape to the environments. If the base environment has a discrete action space with shape ()
, the vectorized version has a multi-discrete action space with shape (n,)
(see https://github.com/Farama-Foundation/Gymnasium/blob/main/gymnasium/vector/utils/space_utils.py#L84).
However, SKRL passes actions with the shape (n, 1)
to the environment in the step
-method of GymnasiumWrapper
, and not with the expected shape (n,)
. This may lead to errors.
Reproduction of bug:
Run the example torch_gymnasium_cartpole_vector_dqn.py
Error:
in gymnasium/envs/classic_control/cartpole.py
lines 165-167: assert self.action_space.contains(action), f"{action!r} ({type(action)}) invalid"
Output:
AssertionError: array([1]) (<class 'numpy.ndarray'>) invalid
What skrl version are you using?
1.4.3
What ML framework/library version are you using?
torch==2.6.0
Additional system information
gymnasium==1.1.1