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

transitions_collate_fn expects next_obs from TransitionsMinimal #860

Open
namheegordonkim opened this issue Oct 23, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@namheegordonkim
Copy link

Bug description

result["next_obs"] = stack_maybe_dictobs([sample["next_obs"] for sample in batch])

While TransitionsMinimal doesn't have the field next_obs, the collate function called during data loading expects there to be next_obs, making TransitionsMinimal unusable with e.g. BC.

Steps to reproduce

import gym
import d4rl
from gymnasium.spaces import Box
import numpy as np

from imitation.algorithms.bc import BC
from imitation.data.types import TransitionsMinimal

env = gym.make("halfcheetah-expert-v2")
dataset = env.get_dataset()
transitions = TransitionsMinimal(obs=dataset["observations"], acts=dataset["actions"], infos=dataset["infos/qpos"])
observation_space = Box(env.observation_space.low, env.observation_space.high, dtype=float)
action_space = Box(env.action_space.low, env.action_space.high, dtype=float)
bc = BC(
    observation_space=observation_space,
    action_space=action_space,
    demonstrations=transitions,
    rng=np.random.default_rng(0),
)
bc.train(n_epochs=1)

Environment

@namheegordonkim namheegordonkim added the bug Something isn't working label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant