stable-baselines icon indicating copy to clipboard operation
stable-baselines copied to clipboard

GAIL throws error when obs space is MultiDiscrete

Open SurferZergy opened this issue 4 years ago • 1 comments

Describe the bug https://stable-baselines.readthedocs.io/en/master/modules/gail.html states that GAIL supports MultiDiscrete obs space, but https://github.com/hill-a/stable-baselines/blob/master/stable_baselines/gail/dataset/record_expert.py ln 50 shows it asserts it is either Discrete or Box, my input is MultiDiscrete and it is throwing the error.

Code example

MultiDiscrete([36 36 51 26 36 36  3 18 26 37 37  3 37 37  3 37 37  3 37 37  3 37 37  3
 37 37  3 37 37  3 37 37  3 37 37  3 37 37  3 37 37  3 37 37  3 37 37  3
 37 37  3 37 37  3 37 37  3 37 37  3 37 37  3 37 37  3 37 37  3 37 37  3
 37 37  3 37 37  3 37 37  3 37 37  3  6  3  6  6  6 37 37 37 37 37 37 37
 37 37 37 26 51 26  4  6  4  5  5  5  5])
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-39-35ba2a80501c> in <module>
     14 # when using something different than an RL expert,
     15 # you must pass the environment object explicitly
---> 16 generate_expert_traj(expert, 'expert', env, n_episodes=10)

/usr/local/lib/python3.6/dist-packages/stable_baselines/gail/dataset/record_expert.py in generate_expert_traj(model, save_path, env, n_timesteps, n_episodes, image_folder)
     49     # Sanity check
     50     assert (isinstance(env.observation_space, spaces.Box) or
---> 51             isinstance(env.observation_space, spaces.Discrete)), "Observation space type not supported"
     52 
     53     assert (isinstance(env.action_space, spaces.Box) or

AssertionError: Observation space type not supported

ps. installed mpi4py

SurferZergy avatar Mar 03 '21 22:03 SurferZergy

Hello, doc should be probably updated (but we having issues with travis now :/) Anyway, I would recommend you to use GAIL implementation from https://github.com/HumanCompatibleAI/imitation which is better maintained (and based on stable-baselines3 now).

araffin avatar Mar 03 '21 22:03 araffin