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

Add Sequence space, update flatten functions #2968

Merged
merged 6 commits into from
Aug 15, 2022

Conversation

Markus28
Copy link
Contributor

@Markus28 Markus28 commented Jul 15, 2022

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 the Graph 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 the Sequence space. However, some changes were necessary to make flattening work for Dict and Tuple spaces that also contain Graph or Sequence spaces.

TODO

  • New tests for flatten functionality, Sequence space
  • Improve docstrings

Copy link
Contributor

@pseudo-rnd-thoughts pseudo-rnd-thoughts left a 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

@@ -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)
Copy link
Contributor

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

def seed(self, seed: Optional[Union[dict, int]] = None) -> list:

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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 :)

@Markus28 Markus28 marked this pull request as ready for review August 11, 2022 12:51
Copy link
Contributor

@pseudo-rnd-thoughts pseudo-rnd-thoughts left a 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

@Markus28
Copy link
Contributor Author

It might actually make sense to move the spaces and samples from test_utils.py to a separate file for better readability

Copy link

@cswinter cswinter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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

Successfully merging this pull request may close these issues.

5 participants