Skip to content

fix: resetting buffer for atari correctly#213

Open
Anton-Gasse wants to merge 1 commit into
danijar:mainfrom
Anton-Gasse:fix_atari_reset
Open

fix: resetting buffer for atari correctly#213
Anton-Gasse wants to merge 1 commit into
danijar:mainfrom
Anton-Gasse:fix_atari_reset

Conversation

@Anton-Gasse
Copy link
Copy Markdown

While I was playing around with the Atari environment I found this little issue when resetting the buffer.

I think the intended behavior is to replace everything in the buffer with the first observation.

However, when the pooling parameter (buffer size) was > 1 then the first element is iteratively overwritten with the other Elements in the buffer (which are initially arrays with only zeros) and therefore the first observation is always a black image.

The error seems to be putting the self.buffers[0] and dst parameters for the np.copyto() method in the wrong order.
According to the numpy documentation the first parameter should be the destination and the second one the source: https://numpy.org/doc/stable/reference/generated/numpy.copyto.html

The implemented switch in this commit should fix this.
I tested it by adding this little testing script to the main.py file and observed that now the first observation is actually an image from the environment and not a black image:

elif config.script == 'test':

      import matplotlib.pyplot as plt
      env = make_env(config, 0)

      action = {"action": np.int32(0),
                "reset": False,
      }
      for _ in range(4):
        obs = env.step(action)
        plt.imshow(obs["image"], cmap="gray")
        plt.show()

I have not tested yet if that change influences any model behavior in the environment.

Hope to hear from you about, if that is helpful.

Cheers,
Anton

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.

1 participant