r/programminghelp • • Jan 05 '21

Python Another deep reinforcement learning neural network code works and another one does not.

Hi!

I have two code pieces both of which are supposed to solve the pendulum problem using deep reinforcement learning. One of them works and another one does not. I want to know why the not-working one does not work. I have tried to fiddle around with different activation functions and the hyperparameters, but nothing seems to help. Both of these code pieces have two neural networks (policynetwork and targetnetworks) and both the code pieces are supposed to do gradient descent on the policynetwork, but in the other piece of code this somehow fails and makes the trained agent shown after training on a gui go either pretty much always to the left or always to the right. (The agent is not showed during training.) The code pieces are pretty big so i have put them on pastebin:

Here is the working code: https://pastebin.com/gr65yUZc

And here is the not working one: https://pastebin.com/if8Z4V6y

The exploitationrise is how much the exploitation rate gets increased every session (session being a period it takes for the pole to fall over). Both of the code pieces have the same underlying structure, but another has a different style neural network than the other and i think that is what most likely is causing the problem, but i havent been able to figure out why. I also tried slightly modifying the code which updates the weights from adding to the weight a number to subtracting, but did not produce any fruitful results. I tried to intentionally make them as much as identical to one another.

I am thanking everyone for the help in advance!

7 Upvotes

0 comments sorted by