Repository navigation
Reset delayed rewards on automatic episode restarts - #384
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #383.
Failure
A dm_env environment may return a
FIRSTtimestep fromstep()when the previous episode has ended, without an explicit call toreset().DelayedRewardWrappercurrently handles clearing accumulated rewards only inside its ownreset().As a result, after a terminal or truncated episode,
DelayedRewardWrapper.step()attempts to add the next episode's initial reward to the old accumulator. A normaldm_env.restart()hasreward=None. With scalar rewards this raises a type error; with nested reward dictionaries, it raises a tree-structure mismatch. The accumulation counter also incorrectly continues across the episode boundary.Change
Handle
timestep.first()immediately after stepping the wrapped environment. Clear the delayed reward buffer and accumulation counter, then return the new episode'sFIRSTtimestep unchanged. This matches the existing explicit-reset semantics and prevents both the exception and cross-episode reward carryover.The normal MID/LAST reward accumulation logic is unchanged, including the flush on episode termination or truncation. This is independent of the
FrameStackingWrapperautomatic-reset work in #376 / #377.Validation
master.DelayedRewardWrapperagainst a deterministicdm_env.Environmentusing realdm-env, NumPy anddm-tree.git diff --checkpass.Scope and limitations
This changes only how an unexpected
FIRSTtimestep is handled instep(). The repository's TensorFlow/Reverb-based full test environment is not installed locally; the focused tests were run with an isolated import harness to avoid those unrelated legacy dependencies. No global training or integration run is claimed.