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 padding_type parameter to FrameSkipObservation and change default to "reset" to preserve backwards comp #830

Merged

Conversation

jamartinh
Copy link
Contributor

Description

FrameStacking as initially (from long time ago) designed filled the buffer with the initial observation from env.reset, I.e. repeated many times as the stacking number.

In the re-implementation the assumption changed to fill it with zeroes, but this not only breaks many codes, it breaks "what is expected" and its proper documentation design.

I have fixed this by using its proper definition:

Note:
        - After :meth:`reset` is called, the frame buffer will be filled with the initial observation.
          I.e. the observation returned by :meth:`reset` will consist of `num_stack` many identical frames.

Fixes #829

Also, I have modified the call to super() with self.env as this is the right way for working with wrappers.
If super() used then unexpected errors can arise when using multiple wrappers.

Type of change

Please delete options that are not relevant.

  • [X ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Screenshots

Please attach before and after screenshots of the change if applicable.

Before:

Original env:
[ 1.25 -0.   -0.   -0.    0.   -0.    0.    0.   -0.   -0.    0.  ]

Stacked env:
[[ 0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.  ]
 [ 0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.  ]
 [ 0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.  ]
 [ 0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.  ]
 [ 1.25 -0.    0.    0.    0.    0.    0.   -0.   -0.    0.    0.  ]]


After:

Original env:
[ 1.25  0.   -0.   -0.    0.   -0.    0.   -0.   -0.   -0.    0.  ]

Stacked env:
[[ 1.25 -0.   -0.   -0.    0.    0.    0.    0.    0.   -0.   -0.  ]
 [ 1.25 -0.   -0.   -0.    0.    0.    0.    0.    0.   -0.   -0.  ]
 [ 1.25 -0.   -0.   -0.    0.    0.    0.    0.    0.   -0.   -0.  ]
 [ 1.25 -0.   -0.   -0.    0.    0.    0.    0.    0.   -0.   -0.  ]
 [ 1.25 -0.   -0.   -0.    0.    0.    0.    0.    0.   -0.   -0.  ]]

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Member

@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.

Thanks for pointing this out.
I implemented with zero as the padding observation due to this is the standard atari implementation / usage.
However I agree that this breaks the prior implementation.

Therefore, I would propose the user having the ability to select the pad observation in __init__ with the options being "zero", "initial", and custom

Add unit test for options same and zero.
Improve documentation of class for the new options.
@pseudo-rnd-thoughts pseudo-rnd-thoughts changed the title Fix to FrameStackObservation and test unit. Add padding_type parameter to FrameSkipObservation and change default to "reset" to preserve backwards comp Dec 17, 2023
@pseudo-rnd-thoughts
Copy link
Member

@jamartinh I have made some changes to your implementation, before I merge, are you happy with the changes and new tests

@jamartinh
Copy link
Contributor Author

Good, thanks!

@pseudo-rnd-thoughts pseudo-rnd-thoughts merged commit d756522 into Farama-Foundation:main Dec 19, 2023
11 checks passed
@jamartinh jamartinh deleted the fix_FrameStackObservation branch December 25, 2023 11:54
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.

[Question] Does FrameStackObservation work as expected?
2 participants