MultiBinary not fully supported
The documentation says that MultiBinary is supported (at least for some of the RL agents), however it looks like the only supported case is MultiBinary(n) where n is an integer. The general case where n is a list of dimensions is not supported. See gym doc.
If the environments uses spaces of the form MultiBinary([,,]) then an exception occurs at the following line because observation_space.n cannot be converted to an int:
https://github.com/DLR-RM/stable-baselines3/blob/b7456392acb921f68a6b9f894350c099726e5a55/stable_baselines3/common/preprocessing.py#L153
The following fix may help though I have not fully tested it so it's possible that it breaks somewhere else:
elif isinstance(observation_space, spaces.MultiBinary):
# Number of binary features
if isinstance(observation_space.n, int):
return (observation_space.n, )
elif isinstance(observation_space.n, list):
return tuple(observation_space.n)
else:
raise NotSupportedError(f"Unsupported type: {type(observation_space.n)}")
See hacked patch at https://github.com/DLR-RM/stable-baselines3/compare/master...blumu:stable-baselines3:blumu/multibinary
Hello,
The documentation says that MultiBinary is supported (at least for some of the RL agents), however it looks like the only supported case is MultiBinary(n) where n is an integer.
This is true.
The general case where n is a list of dimensions is not supported. See gym doc.
The easiest solution would be to use a wrapper to flatten/unflatten the observation, no?
Anyway, the env checker should be updated at least.