D4RL
D4RL copied to clipboard
[Bug Report] d4rl.sequence_dataset raise error when handling mujoco-v2 environments
Describe the bug
As the title says, when applying d4rl.sequence_dataset
on a v2
environment of d4rl-mujoco, you get an error of:
IndexError Traceback (most recent call last)
Cell In [1], line 5
3 env = gym.make('walker2d-medium-replay-v2')
4 dataset = d4rl.sequence_dataset(env)
----> 5 dataset = list(dataset)
File ~/miniconda3/envs/video-pretraining/lib/python3.9/site-packages/d4rl/__init__.py:175, in sequence_dataset(env, dataset, **kwargs)
172 final_timestep = (episode_step == env._max_episode_steps - 1)
174 for k in dataset:
--> 175 data_[k].append(dataset[k][i])
177 if done_bool or final_timestep:
178 episode_step = 0
IndexError: invalid index to scalar variable.
Looked slight deeper, the bug is triggered since there are metadatas in the v2
datasets which are not arrays. An easy solution to this problem is to skip any keys that start with metadata/
. But I am not sure that is the intended behaviour of this library.
Code example
import gym
import d4rl
env = gym.make('walker2d-medium-replay-v2')
dataset = d4rl.sequence_dataset(env)
dataset = list(dataset)
System Info Describe the characteristic of your environment:
-
D4RL
is installed bypip install git+https://github.com/Farama-Foundation/d4rl@master#egg=d4rl
- System: Linux
- Python: 3.9.13
Additional context no.
Checklist
- [x] I have checked that there is no similar issue in the repo (required)