Skip to content

Commit

Permalink
[Feature] Dict specs in vmas (pytorch#2415)
Browse files Browse the repository at this point in the history
Co-authored-by: Vincent Moens <vmoens@meta.com>
  • Loading branch information
matteobettini and vmoens authored Sep 4, 2024
1 parent 49d7f74 commit df4fa78
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions torchrl/envs/libs/vmas.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ def _vmas_to_torchrl_spec_transform(
device=device,
)
)
elif isinstance(spec, gym_spaces.Dict):
spec_out = {}
for key in spec.keys():
spec_out[key] = _vmas_to_torchrl_spec_transform(
spec[key],
device=device,
categorical_action_encoding=categorical_action_encoding,
)
# the batch-size must be set later
return Composite(spec_out, device=device)
else:
raise NotImplementedError(
f"spec of type {type(spec).__name__} is currently unaccounted for vmas"
Expand Down

0 comments on commit df4fa78

Please sign in to comment.