Closed FoConrad closed 6 years ago
I've run the code and can verify the phenomena mentioned in the issue. Still not sure what caused the problem. However, I think Adam should be correct as the weights are the same at the earlier iterations.
@FoConrad @sxjscience I also implemented PPO using mxnet-gluon, but the performance is much worse than the OpenAi baseline. Is it really caused by the Adam optimizer in MXNet? Have you solved this problem?
The PPO paper primarily depended on SGD and used Adam only as an alternative for better performance. Given he online nature of the problem, I would be surprised if SGD makes a fundamental difference.
Also, while the KL term stabilizes the objective and good to have, PPO may be too conservative if there is no explicit exploration. Weight divergence is expected in the end: any optimal policies must be deterministic, i.e. saturate (except in adversarial bandits).
There were some reproducibility discussions around PPO and TRPO. You may want to try a few more seeds on the original baseline as well.
My 2cents.
It turns out the primary cause for our performance problem was solved after making this post, but I was still stuck on tracing down the cause of the weight divergence. Digging in to both implementation of Adam, it seemed that, at least algebraically, both were computing the same thing (and, in the example above, all hyper-parameters were set the same).
My best guess for the weight divergence is simply the order of operations in which things are calculated. Once weights start to diverge (and they diverge between MXNet and TF even after a single tanh) to a large enough amount, then they will continue to diverge as the gradients of each will be different.
This is not a very satisfying answer, but seems to be the case.
@FoConrad thanks for your replay. I also recently implemented the PPO algorithm using mxnet, but the training is very slow on breakout game(gym) -- total timestep=10M, the eposide score is only 45.
how do you solve the performance of PPO algorithm.
The way I debugged the implementation is similar to the code I posted above. I ran the OpenAI baselines code with my implementation of PPO, made sure they were initialized the same, and stepped through comparing the weights and gradients.
I found immediately my value function was incorrect.
Also, double check your initialization to begin with. Sometimes PPO was very sensitive to the weight initialisation.
Hope this helps!
Description
We noticed our gluon/MXNet Proximal Policy Optimization (PPO) implementation is under-performing compared to the OpenAI Baselines version in TensorFlow. Upon inspection it appears that this may be, in part, to the Adam optimizer in MXNet.
This is seen by initializing both networks with the same parameters, and taking very much care that all the computation is equivalent (which can be seen by using another optimizer, aside from Adam, and noting the weights of the two networks progress with nearly the same values), and noting that the weights start to diverge significantly. The weight divergence only occurs on the Policy network (and occurs with or without the entropy term).
Environment info (Required)
Ubuntu 16.04 CPU: Intel(R) Xeon(R) CPU E5-1620 v3 @ 3.50GHz MXNet version: 1.1.0 TensorFlow version: 1.4.1 Numpy version: 1.13.1
I'm using Python 3.5.2.
Minimum reproducible example
Provided is the script mnist.py (below). This file requires TensorFlow and MXNet. It uses the MNIST dataset to reproduce the weight divergence (when initialized to the exact same weight values) between a simple gluon network and an equivalent TensorFlow one. This example was carefully crafted so that the TensorFlow code contained is in essence equivalent to OpenAI baselines implementation of PPO (some non-contributing factors were whittled away for a more simple example).
The code, understandably, may not actually be training a significant MNIST classifier. Instead, it is meant to mirror the PPO policy objective, and track the weight progression.
Find the code here.
Steps to reproduce
python mnist.py # Shows weight divergence using Adam
python mnist.py --optimizer momentum # Shows weight divergence is insignificant with other optimizer
What have you tried to solve it?