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

Pass env_id to replay buffer methods to correctly support batch training #442

Merged
merged 8 commits into from
May 23, 2019

Conversation

muupan
Copy link
Member

@muupan muupan commented Apr 12, 2019

Merge #443 before this PR.

Current replay buffers with num_steps > 1 or episodic are not correct in batch training because they cannot know which env a given transition came from.

This PR adds the env_id argument to two methods of replay buffers: append and stop_current_episode. From env_id replay buffers can know which env a given transition came from and which env's episode is stopped.

TODO:

  • check how it affects scores with n-step return and batch training

to correctly handles when episodes end in batch training
@muupan muupan changed the title Pass env_id to replay buffer methods to correctly handles when episodes end in batch training Pass env_id to replay buffer methods to correctly support batch training Apr 12, 2019
@muupan muupan changed the title Pass env_id to replay buffer methods to correctly support batch training [WIP] Pass env_id to replay buffer methods to correctly support batch training Apr 12, 2019
@muupan muupan added the bug label Apr 15, 2019
@muupan
Copy link
Member Author

muupan commented Apr 18, 2019

I checked the effect of the bug fixed by this PR. I added the --n-step-return option to examples/ale/train_dqn_batch_ale.py and run it with --n-step-return 1 and --n-step-return 3, using 3 different random seeds:

python3 examples/ale/train_dqn_batch_ale.py --num-envs 8 --n-step-return 1 --steps 10000000 --env SpaceInvadersNoFrameskip-v4
python3 examples/ale/train_dqn_batch_ale.py --num-envs 8 --n-step-return 3 --steps 10000000 --env SpaceInvadersNoFrameskip-v4

Before this PR, --n-step-return 3 completely failed. After this PR, --n-step-return 3 learned faster than --n-step-return 1 as expected.

image

@muupan muupan changed the title [WIP] Pass env_id to replay buffer methods to correctly support batch training Pass env_id to replay buffer methods to correctly support batch training Apr 18, 2019
# It should have:
# - 4 transitions from env_id=1
# - 5 transitions from env_id=2
self.assertEqual(len(rbuf), 9)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we have 3 transitions? One from env_id=1 and five from env_id=2?

Copy link
Member Author

@muupan muupan May 23, 2019

Choose a reason for hiding this comment

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

Four from env_id=1: (s_0, s_4), (s_1, s_4), (s_2, s_4), and (s_3, s_4), since the transition to s_4 is terminal.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it.

@chainer chainer deleted a comment from muupan May 23, 2019
Copy link
Contributor

@prabhatnagarajan prabhatnagarajan 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 to me. Merge at will.

# It should have:
# - 4 transitions from env_id=1
# - 5 transitions from env_id=2
self.assertEqual(len(rbuf), 9)
Copy link
Contributor

Choose a reason for hiding this comment

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

Got it.

@prabhatnagarajan prabhatnagarajan merged commit 350b257 into chainer:master May 23, 2019
@muupan muupan deleted the add-env-id-to-replay-buffer branch May 23, 2019 05:14
@muupan muupan added this to the v0.7 milestone Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants