Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] d4rl.sequence_dataset raise error when handling mujoco-v2 environments #222

Open
1 task done
IcarusWizard opened this issue Sep 18, 2023 · 0 comments
Open
1 task done

Comments

@IcarusWizard
Copy link

IcarusWizard commented Sep 18, 2023

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 by pip install git+https://github.com/Farama-Foundation/d4rl@master#egg=d4rl
  • System: Linux
  • Python: 3.9.13

Additional context
no.

Checklist

  • I have checked that there is no similar issue in the repo (required)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant