-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Add Sequence
space, update flatten
functions
#2968
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, a minor point on the seeding
Would you be able to check this against my updated seed testing PR, this should simplify the testing additions
#2977
Are we adding the utils.py function support? Otherwise, just raise an error explaining why I think
gym/spaces/sequence.py
Outdated
@@ -38,6 +38,11 @@ def __init__( | |||
None, None, seed # type: ignore | |||
) # None for shape and dtype, since it'll require special handling | |||
|
|||
def seed(self, seed: Optional[int] = None) -> list: | |||
"""Seed the PRNG of this space and the feature space.""" | |||
super().seed(seed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally the seeding for composite spaces includes the super seed list
Line 103 in 8b74413
def seed(self, seed: Optional[Union[dict, int]] = None) -> list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying that I should change the typehint to seed: Any = None
? I can see how that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is what I mean
seeds = super().seed(seed)
seeds += self.feature_space.seed(seed)
return seeds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh, of course. I'm adding that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, the number of tests is impressive.
Could we confirm with the entity space team that this is good before merging
It might actually make sense to move the spaces and samples from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
We are trying to integrate some of the functionality from https://github.com/entity-neural-network/entity-gym into Gym. We agreed that the best first step would be to implement a
Sequence
space that models arbitrary-length sequences.This leads to some problems because we cannot flatten arbitrary-length sequences to a
Box
in a reasonable way. The same problem exists for theGraph
space. Currently, flattening a graph just means flattening the node and edge feature spaces. This seems quite reasonable to me and I took the same approach for theSequence
space. However, some changes were necessary to make flattening work forDict
andTuple
spaces that also containGraph
orSequence
spaces.TODO
Sequence
space