Seyed Masoud Hosseini · Overview · Study log · Weekly summaries · Ideas · Search · Transcript · RSS feed

Deep Learning for Computer Vision · Lecture 14 of 16 · 1:04:01

Lecture 14: Deep Reinforcement Learning

Lecture 14 | Deep Reinforcement Learning on YouTube

Study guide

What this lecture covers

The lecture moves from supervised and unsupervised learning, covered earlier in the course, into a third problem setup: an agent that takes actions in an environment and learns from rewards rather than labels. It formalizes this as a Markov decision process (MDP) and builds up the two main families of deep reinforcement learning algorithms, Q-learning and policy gradients, showing how each one is derived, trained, and where it succeeds or struggles.

By the end, you can describe an RL problem as states, actions, and rewards, explain the Bellman equation and why plain Q-learning does not scale, and follow how deep Q-networks, policy gradient methods (REINFORCE), and actor-critic combine the two. The lecture closes with two applied examples, a recurrent visual attention model and DeepMind's AlphaGo, that show these ideas used in vision and game-playing systems.

Key ideas

  • Markov decision process (MDP): a tuple of states, actions, a reward distribution, a transition probability distribution, and a discount factor, used to formalize the agent-environment loop.
  • Policy: a function from states to actions; the objective is to find the policy that maximizes expected cumulative discounted reward.
  • Value function and Q-value function: the value function estimates expected future reward from a state under a policy; the Q-value function estimates it for a state-action pair.
  • Bellman equation: the optimal Q-value of a state-action pair equals the immediate reward plus the discounted value of the best action in the next state.
  • Deep Q-learning: approximates the Q-function with a neural network trained to satisfy the Bellman equation, made stable in practice with experience replay.
  • Policy gradients (REINFORCE): directly optimize policy parameters with gradient ascent on expected reward, using a Monte Carlo estimator that avoids needing transition probabilities.
  • Variance reduction: techniques such as using future rewards only, discounting, and subtracting a baseline (including a learned value function) reduce the high variance of policy gradient estimates.
  • Actor-critic: combines a policy network (actor) with a learned Q or value function (critic) that scores the actor's actions using the advantage function.

Walkthrough

The reinforcement learning problem (1:09)

The lecture contrasts RL with supervised and unsupervised learning: here an agent receives a state, takes an action, and gets back a reward and a new state, repeating until a terminal state ends the episode. It walks through examples including cart-pole, robot locomotion, Atari games, and Go, identifying the state, action, and reward for each.

Markov Decision Process (6:15)

The MDP formalism is introduced as a tuple of states, actions, a reward distribution, a transition distribution, and a discount factor. The lecture works through the agent-environment loop mathematically and defines a policy as a mapping from states to actions, with the goal of finding the policy that maximizes cumulative discounted reward.

Grid World, value functions and Q-learning (8:19)

A simple Grid World example illustrates random versus optimal policies. The lecture then defines the value function and Q-value function, derives the Bellman equation for the optimal Q-function, and explains why naive value iteration over all state-action pairs is computationally infeasible for large state spaces such as raw game pixels.

Deep Q-learning with experience replay (15:28)

The fix is to approximate the Q-function with a neural network trained to reduce the error against the Bellman target, which is deep Q-learning. Applied to Atari, the network takes a stack of the last four preprocessed frames and outputs one Q-value per action in a single forward pass. Experience replay, storing transitions and training on random mini-batches instead of consecutive ones, is introduced to break correlations between samples and improve data efficiency. The full deep Q-learning with experience replay algorithm is assembled step by step, and a video shows a DQN agent learning to play Breakout over the course of training.

Policy gradients and REINFORCE (28:38)

When the Q-function is too complex to learn but the policy is simpler, the lecture introduces policy gradients: parametrize the policy directly and take gradient ascent on expected reward. It derives the REINFORCE gradient estimator using the log-derivative trick to avoid differentiating through unknown transition probabilities, and explains the intuition of pushing up the probability of actions from high-reward trajectories and down for low-reward ones.

Reducing variance and actor-critic (36:48)

Because the basic REINFORCE estimator has high variance, the lecture presents variance-reduction tricks: scaling by future reward only, discounting, and subtracting a baseline. It connects a good baseline to the value function, arrives at the advantage function Q(s,a) - V(s), and combines policy gradients with a learned critic in the actor-critic algorithm, which can reuse Q-learning tricks like experience replay.

Applications: recurrent attention and AlphaGo (46:55)

Two case studies close the lecture. The recurrent attention model uses policy gradients to choose where to glimpse next in an image for classification, since choosing glimpse locations is non-differentiable; it has also been applied to fine-grained recognition, captioning, and visual question answering. AlphaGo is presented as combining supervised pretraining on professional games, self-play policy gradient training, a learned value network, and Monte Carlo tree search to select moves.

Before you watch

  • Review supervised and unsupervised learning from earlier lectures, since this lecture defines RL by contrast with both.
  • Be comfortable with gradient descent and neural network training, as Q-learning and policy gradients both reduce to gradient-based optimization.
  • Basic familiarity with probability distributions and expectations helps with the Bellman equation and the REINFORCE derivation.

Check your understanding

  1. What are the components of a Markov decision process, and what does each one represent?
  2. How does the Bellman equation relate the optimal Q-value of a state-action pair to the value of the next state?
  3. Why does plain Q-learning become infeasible for large state spaces, and how does deep Q-learning with experience replay address this?
  4. What problem does the log-derivative trick solve in deriving the policy gradient estimator?
  5. Why does the actor-critic algorithm need both a policy network and a critic, and how does the advantage function fit in?

Vocabulary

reinforcement learning (RL) (noun)
A learning approach where an agent learns by taking actions and receiving rewards.
Reinforcement learning trains agents through trial and reward.
agent (noun)
The learner or decision-maker that interacts with an environment.
The agent chooses actions based on the current state.
environment (noun)
The world or system an agent interacts with.
The agent receives feedback from the environment.
reward (noun)
A numerical signal telling the agent how good or bad its action was.
The agent tries to maximize its total reward.
state (noun)
A description of the current situation the agent is in.
Each state represents one configuration of the environment.
terminal state (noun)
A final state where an episode of interaction ends.
The game ends when the agent reaches a terminal state.
episode (noun)
One complete sequence of interaction from start to finish.
Training runs many episodes to improve the policy.
policy (noun)
A rule that maps states to actions.
The optimal policy maximizes expected reward.
cumulative reward (noun)
The total reward collected over time, often discounted.
The agent tries to maximize cumulative discounted reward.
Q-value function (noun)
A function estimating the expected future reward of taking an action in a state.
The Q-value function helps decide which action is best.
Bellman equation (noun)
An equation relating a state's value to the reward and value of future states.
The Bellman equation defines the optimal Q-value.
deep Q-learning (noun)
A method that uses a neural network to approximate the Q-value function.
Deep Q-learning trained an agent to play Atari games.
experience replay (noun)
A technique that stores past experiences and samples them randomly for training.
Experience replay breaks correlations between training samples.
policy gradient (noun)
A method that directly optimizes a policy's parameters using gradients.
Policy gradients avoid needing a Q-function.
log-derivative trick (noun)
A mathematical trick used to compute gradients without knowing transition probabilities.
The log-derivative trick makes policy gradients possible.
variance reduction (noun)
Techniques that make noisy estimates more stable and reliable.
Variance reduction improves policy gradient training.
baseline (RL) (noun)
A reference value subtracted from reward to reduce noise in training.
Subtracting a baseline reduces the variance of the gradient estimate.
advantage function (noun)
A measure of how much better an action is compared to the average action in a state.
The advantage function guides actor-critic training.
actor-critic (noun)
A method combining a policy (actor) and a value estimator (critic).
Actor-critic combines the strengths of policy gradients and value learning.
self-play (noun)
A training method where an agent improves by playing against itself.
AlphaGo used self-play to improve its policy.
Monte Carlo tree search (noun)
A search algorithm that explores possible future moves using random sampling.
AlphaGo combines Monte Carlo tree search with learned networks.

Chapters

From the YouTube description

In Lecture 14 we move from supervised learning to reinforcement learning (RL), in which an agent must learn to interact with an environment in order to maximize its reward. We formalize reinforcement learning using the language of Markov Decision Processes (MDPs), policies, value functions, and Q-Value functions. We discuss different algorithms for reinforcement learning including Q-Learning, policy gradients, and Actor-Critic. We show how deep reinforcement learning has been used to play Atari games and to achieve super-human Go performance in AlphaGo.

Keywords: Reinforcement learning, RL, Markov decision process, MDP, Q-Learning, policy gradients, REINFORCE, actor-critic, Atari games, AlphaGo

Slides: http://cs231n.stanford.edu/slides/2017/cs231n_2017_lecture14.pdf

--------------------------------------------------------------------------------------

Convolutional Neural Networks for Visual Recognition

Instructors:
Fei-Fei Li: http://vision.stanford.edu/feifeili/
Justin Johnson: http://cs.stanford.edu/people/jcjohns/
Serena Yeung: http://ai.stanford.edu/~syyeung/

Computer Vision has become ubiquitous in our society, with applications in search, image understanding, apps, mapping, medicine, drones, and self-driving cars. Core to many of these applications are visual recognition tasks such as image classification, localization and detection. Recent developments in neural network (aka “deep learning”) approaches have greatly advanced the performance of these state-of-the-art visual recognition systems. This lecture collection is a deep dive into details of the deep learning architectures with a focus on learning end-to-end models for these tasks, particularly image classification. From this lecture collection, students will learn to implement, train and debug their own neural networks and gain a detailed understanding of cutting-edge research in computer vision.

Website:
http://cs231n.stanford.edu/

For additional learning opportunities please visit:
http://online.stanford.edu/

← Lecture 13: Generative Models · Lecture 15: Efficient Methods and Hardware for Deep Learning →