I have two different implementations with PyTorch of the Atari Pong game using A2C algorithm. Both implementations are similar, but some portion are different.
The above code is from the following Github repository: https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On/blob/master/Chapter10/02_pong_a2c.py It converged perfectly well!
You can find an explanation in Maxim Lapan's book Deep Reinforcement Learning Hands-on page 269
Here is the mean reward curve :
The above implementation has been created by me based on the Maxim Lapan's book. However, the code is not converging. There's a small portion of my code that is wrong, but I can't point out what it is. I've been working on that near a week now.
Here is the mean reward curve :
Can someone tell me the problem portion of the code and how can I fix it?
UPDATE 1
I have decided to test my code with a simpler environment, i.e. Cartpole-v0
.
Here is the code : https://colab.research.google.com/drive/1zL2sy628-J4V1a_NSW2W6MpYinYJSyyZ?usp=sharing
Even that code doesn't seem to converge. Still can't see where is my problem.
UPDATE 2
I think the bug might be in the ExperienceSource class or in the Agent class.
UPDATE 3
The following question will help you understand the classes ExperienceSource
and ExperienceSourceFirstLast
.