techlist.io

Dqn

2 posts

OpenAI2017-07-263 min readCurated summary

Better exploration with parameter noise

# Better Exploration with Parameter Noise Adding adaptive noise to the parameters of reinforcement learning policies, rather than to their actions, often improves performance. The method is simple to implement, rarely hurts results, and lets agents learn tasks much faster. On the HalfCheetah environment, a policy trained with parameter noise reached a score of about 3,000 after 20 episodes, while one trained with traditional action noise reached about 1,500. ## How Parameter Noise Differs from Action Noise - Traditional reinforcement learning explores by adding noise to the action space, which changes the probabilities of actions from one moment to the next. - Parameter noise instead perturbs the weights of the neural network policy, so the agent's decisions still depend fully on what it currently senses. - The approach sits between evolution strategies, which perturb parameters but not actions during rollouts, and methods like TRPO, DQN, and DDPG, which perturb actions but leave parameters untouched. - The authors believe the advantage comes from consistency: deliberate parameter perturbations produce exploration that persists across timesteps, while action noise produces erratic exploration unrelated to the agent's parameters. - Earlier work applied parameter noise to policy gradients, but this research extends it to deep neural network policies and to both on-policy and off-policy algorithms. ## Solving the Three Main Challenges - **Varying layer sensitivity:** Different layers respond differently to perturbations. Layer normalization keeps each perturbed layer's output within a similar distribution, so the next layer receives stable inputs. - **Shifting sensitivity over training:** The weights' sensitivity changes as training progresses, making behavior hard to predict. An adaptive scheme resizes the perturbations by measuring their effect on actions and comparing the resulting action-space noise level to a target. - **Choosing the noise scale:** Parameter noise is hard to interpret intuitively. The adaptive scheme moves the scale decision into action space, which is easier to reason about. ## Baselines and Benchmarks - The release includes baseline code for DQN, Double DQN, Dueling DQN, Dueling Double DQN, and DDPG with parameter noise. - Benchmarks compare DDQN with and without parameter noise on a subset of Atari games. - Benchmarks also compare three DDPG variants on a range of continuous control tasks in the MuJoCo simulator. ## Development Lessons - In early experiments, perturbing the DQN Q-function sometimes was so extreme that the agent repeated the same action. The team added a separate explicit policy head, as in DDPG, to work around this. - Later experiments showed the policy head was unnecessary. Changing how the noise was rescaled had likely fixed the underlying problem, so the simpler version performed comparably. - The authors note that reinforcement learning algorithms can fail silently and subtly, which can lead engineers to build workarounds around bugs they never noticed. ## Practical Takeaway Parameter noise is worth trying on any reinforcement learning problem. It is simple to add, rarely reduces performance, and can speed up learning considerably, especially when paired with layer normalization and adaptive scaling.

OpenAI2017-05-233 min readCurated summary

OpenAI Baselines: DQN

# OpenAI Baselines: DQN OpenAI is open-sourcing Baselines, an internal library of reinforcement learning algorithms whose implementations are verified to match published results. The first release includes DQN and three of its variants, and the authors argue that known-good implementations make it harder for apparent RL advances to come from comparisons against buggy or undertuned baselines. The post pairs the release with practical advice on avoiding the bugs that commonly make RL results hard to reproduce. ## Why RL Results Are Hard to Reproduce - Performance is very noisy, so results can look like progress when they are not. - Algorithms have many interacting parts, and subtle bugs can hide inside them. - Papers often omit tricks that are needed to reach the reported performance. ## Practical Debugging Practices - **Compare against a random baseline.** An agent taking random actions can appear to learn early in training, as seen in the H.E.R.O. example, so an agent should always outperform a random one to show real learning. - **Watch for silent bugs.** In a review of ten popular RL reimplementations, six had subtle bugs confirmed by their authors. These ranged from ignored gradients and incorrect causal convolutions to implementations reporting scores higher than the true results. - **Inspect what the agent sees.** Converting frames to grayscale with miscalibrated green-channel coefficients erased the fish in Seaquest, which caused poor performance. Gym's new `play` function lets researchers view the same observations the agent receives. - **Fix bugs before tuning hyperparameters.** Bugs can push researchers toward compensating hyperparameter choices. Epsilon annealing had a large effect on performance, with the final schedule decreasing it to 0.1 over the first million steps and then to 0.01 over the next 24 million. - **Interpret papers carefully.** The DQN Nature paper's instruction to clip the error term to between -1 and 1 can mean clipping the objective, which zeroes gradients for high-error transitions, or clipping the gradient multiplier, which corresponds to Huber loss. The second interpretation is the correct one. Checking gradients with TensorFlow's `compute_gradients` can reveal such mistakes. - **Review code repeatedly.** Most bugs were found by re-reading the code line by line and asking what could go wrong, and experienced researchers often underestimate how many passes this takes. ## The Released Algorithms - **DQN:** Combines Q-learning with deep neural networks so RL can handle high-dimensional inputs such as video games and robotics. - **Double Q-learning:** Reduces the tendency of DQN to overestimate action values. - **Prioritized Replay:** Extends experience replay by sampling transitions where actual and expected rewards differ significantly. - **Dueling DQN:** Splits the network into a value stream and an advantage stream, which are combined into a single action-value estimate. ## Getting Started The release installs with `pip install baselines`. Users can train a CartPole model with `baselines.deepq.experiments.train_cartpole`, then visualize the learned policy with `enjoy_cartpole`. Pretrained Atari agents are also available, such as a dueling, prioritized-replay Breakout model that can be downloaded and run with the `atari.download_model` and `atari.enjoy` scripts. ## Benchmarks An included notebook compares the Atari performance of the DQN variants, including Dueling Double Q-learning with Prioritized Replay, Double Q-learning with Prioritized Replay, Dueling Double Q-learning, and Double Q-learning. ## Conclusion Reusable, verified implementations let researchers spend less time reimplementing existing algorithms and more time designing new ones. Anyone reproducing RL results should check against a random baseline, inspect the agent's observations, fix bugs before tuning, verify ambiguous paper details through gradient checks, and review the code thoroughly.