1. Home
  2. Explore
  3. Computer Science
  4. Deep Reinforcement Learning

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Deep Reinforcement Learning

  • 46Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Deep RL Fundamentals

What is deep reinforcement learning?

46 questions

  1. 1

    What is deep reinforcement learning?

    Model answer

    Deep reinforcement learning is the combination of deep learning and reinforcement learning, where neural networks are used as function approximators in RL algorithms.

    Explanation

    Traditional RL uses tables or linear functions; deep RL uses neural networks to handle large state/action spaces, enabling applications like playing Atari games from raw pixels.

  2. 2

    How does reinforcement learning differ from supervised learning?

    Model answer

    Supervised learning teaches by example using labeled data, while reinforcement learning teaches by experience, where the agent learns from rewards and punishments through interaction with an environment.

    Explanation

    In supervised learning, the model is trained on input-output pairs; in RL, the agent must explore and learn from delayed rewards, making decisions in sequences without explicit supervision.

  3. 3

    Give three applications of reinforcement learning besides gaming.

    Model answer

    Autonomous driving, robotics control, and advertising/marketing.

    Explanation

    The lecture mentions autonomous driving for dynamic planning, robotics for movement control, and advertising for long-term strategies like real-time bidding.

  4. 4

    Why is supervised learning insufficient for solving the game of Go?

    Model answer

    Supervised learning cannot cover all possible board states, may learn from suboptimal moves, lacks understanding of long-term strategies, and has an ill-defined ground truth since even experts are not perfect.

    Explanation

    The state space is enormous (13x13 grid with three possibilities per intersection). Historical data from professionals misses many states, moves may be bad, and the model cannot infer strategy from single moves. The best humans are not the best possible players.

  5. 5

    What is the key idea of reinforcement learning in one sentence?

    Model answer

    Reinforcement learning is about making good sequences of decisions to maximize cumulative reward.

    Explanation

    The lecture defines RL as 'making good sequences of decisions' or 'making sequences of good decisions' and emphasizes maximizing the return (sum of discounted rewards).

  6. 6

    In the AlphaGo documentary, why did AlphaGo make a move that seemed unintuitive to humans?

    Model answer

    AlphaGo was programmed to maximize its probability of winning, not the margin of victory, so it made moves that secured a win by a small margin, which may appear suboptimal to humans who aim to win by a large margin.

    Explanation

    Humans are trained to maximize their advantage (e.g., capture many stones), but AlphaGo only cares about winning, leading to counterintuitive but strategically sound moves.

  7. 7

    What is the difference between value-based RL and policy-based RL?

    Model answer

    Value-based RL (e.g., Q-learning) learns a value function and derives a policy by taking actions with highest value, while policy-based RL (e.g., PPO) directly learns a policy (probability distribution over actions).

    Explanation

    In value-based methods, the policy is implicit (e.g., argmax of Q). Policy-based methods output action probabilities and work well with continuous action spaces.

  8. 8

    Define the terms agent, environment, state, action, reward, and observation in reinforcement learning.

    Model answer

    Agent: the learner/decision-maker. Environment: everything the agent interacts with. State: a representation of the current situation (s_t). Action: a decision taken by the agent (a_t). Reward: immediate feedback signal (r_t). Observation: what the agent perceives (o_t), which may be a partial view of the state.

    Explanation

    The agent interacts with the environment over time steps. At each step, the agent receives an observation and reward, takes an action, and the environment transitions to a new state.

  9. 9

    Why is there a distinction between state and observation in RL?

    Model answer

    The observation may be only a partial view of the full state, as in games with fog of war where the agent cannot see the entire environment.

    Explanation

    In games like Starcraft or League of Legends, the agent only sees parts of the map. The state contains all information, but the observation is what the agent actually perceives.

  10. 10

    What is a terminal state in reinforcement learning?

    Model answer

    A terminal state is a state that ends an episode; when reached, no further actions are taken, and the agent typically receives a final reward and then resets to an initial state.

    Explanation

    In the recycling example, states 1 (garbage can) and 5 (recycle bin) are terminal. Reaching them ends the game and the agent starts a new episode from state 2.

  11. 11

    What is the discount factor gamma and why is it used in RL?

    Model answer

    The discount factor gamma (0<γ≤1) represents the diminishing value of future rewards, analogous to the time value of money or energy consumption, encouraging the agent to prefer shorter paths to rewards.

    Explanation

    A discount factor less than 1 makes the agent prioritize immediate rewards over distant ones. It is a hyperparameter that influences strategy.

  12. 12

    What is the return in reinforcement learning?

    Model answer

    The return is the total discounted sum of rewards over an episode: R = r_0 + γ r_1 + γ^2 r_2 + ...

    Explanation

    The lecture defines the return as capital R, which the agent aims to maximize. It accounts for immediate and future rewards with discounting.

  13. 13

    In the recycling example with gamma=0.9, what is the optimal return from state 2?

    Model answer

    The optimal return from state 2 is 9, achieved by going right twice then right again to the recycle bin (reward 1+0.910=10, discounted from state 2 gives 0.910=9).

    Explanation

    Backtracking: from state 3, max return is 1+0.910=10. From state 2, going right gives 0+0.910=9; going left gives 2 (terminal). So optimal return is 9.

  14. 14

    What is the Bellman optimality equation for the optimal Q-function?

    Model answer

    Q*(s,a) = r + γ * max_{a'} Q*(s', a'), where s' is the next state after taking action a.

    Explanation

    This equation states that the optimal Q-value of a state-action pair equals the immediate reward plus the discounted optimal Q-value of the best action in the next state.

  15. 15

    What is a policy in reinforcement learning?

    Model answer

    A policy is a function that maps states to actions, telling the agent what action to take in each state. In Q-learning, the policy is greedy: π(s) = argmax_a Q(s,a).

    Explanation

    The lecture defines policy as the function that tells you the best strategy. In Q-learning, it is the argmax over actions of the Q-values.

  16. 16

    What is a transition in reinforcement learning?

    Model answer

    A transition is the process of moving from state s_t to s_{t+1} by taking action a_t, receiving reward r_t and observation o_t.

    Explanation

    The lecture describes a transition as getting from state t to t+1 after an action, observing reward and observation.

  17. 17

    In the recycling example, what is the immediate reward for going from state 2 to state 1 (left)?

    Model answer

    The immediate reward is +2 for throwing garbage in the normal can.

    Explanation

    The lecture specifies reward +2 for reaching the garbage can (state 1) from state 2.

  18. 18

    How is a Q-table initialized and filled in the recycling example?

    Model answer

    Initially the Q-table is empty or zero. Then by backtracking from terminal states using the Bellman equation, the Q-values are computed: for each state-action pair, Q(s,a) = immediate reward + γ * max_a' Q(s',a').

    Explanation

    The lecture shows the tree of immediate rewards and then computes discounted returns backward. For example, Q(s3, right) = 1 + 0.9*10 = 10.

  19. 19

    Why is a Q-table impractical for large state/action spaces?

    Model answer

    A Q-table grows with the number of states and actions; for games like Go with 13x13 board, the number of possible states is astronomically large, making storage and lookup impossible.

    Explanation

    The lecture notes that a matrix discovered through backtracking becomes impossible for large spaces, motivating the use of neural networks as function approximators.

  20. 20

    How does a deep Q-network (DQN) overcome the Q-table limitation?

    Model answer

    Instead of a table, DQN uses a neural network that takes a state as input and outputs Q-values for each action, acting as a universal function approximator.

    Explanation

    The neural network is trained to approximate the optimal Q-function. Given a state, it directly outputs the Q-values, avoiding the need to store all state-action pairs.

  21. 21

    What is the input and output of a DQN for playing Breakout?

    Model answer

    Input: preprocessed game frames (e.g., 4 grayscale, cropped frames stacked). Output: Q-values for each possible action (e.g., left, right, idle).

    Explanation

    The lecture discusses using the screen as input, converting to grayscale, cropping, and stacking history of 4 frames to capture motion. Output is Q-values for the three actions.

  22. 22

    Explain the loss function used in DQN training.

    Model answer

    The loss is the mean squared error between the predicted Q-value Q(s,a) and the target Y = r + γ * max_{a'} Q(s', a') (or just r if s' is terminal).

    Explanation

    The target Y is computed using the Bellman equation, and the network is updated to minimize this squared error, similar to supervised regression.

  23. 23

    How is the target Y computed for a non-terminal transition in DQN?

    Model answer

    Y = r + γ * max_{a'} Q(s', a'), where s' is the next state and the max is taken over actions using the same Q-network.

    Explanation

    This requires a second forward pass on s' to get Q(s',a') for all actions, then taking the maximum. This target is treated as fixed during gradient descent.

  24. 24

    Why must the target Y be treated as fixed during gradient descent in DQN?

    Model answer

    Because the target Y depends on the Q-network parameters; differentiating through it would complicate the update, so it is treated as a constant (no gradient flows through it).

    Explanation

    The lecture explains that Y is dependent on the network, but we 'hold it fixed' so that only the predicted Q(s,a) is differentiated, simplifying training.

  25. 25

    In the DQN training loop, why do we need two forward passes per step?

    Model answer

    One forward pass on the current state s to get Q(s,a) for the action taken, and another forward pass on the next state s' to compute max Q(s',a') for the target.

    Explanation

    The target requires Q(s',a') values, so after executing action a and observing s', we feed s' into the network to get the max Q-value.

  26. 26

    What is the pseudo code for vanilla Q-learning (without experience replay)?

    Model answer

    Initialize Q-network parameters. Loop over episodes: start from initial state s. Loop until terminal: forward propagate s, execute action a with max Q, observe reward r and next state s', compute target Y, perform gradient descent on (Y - Q(s,a))^2, set s = s'.

    Explanation

    The lecture walks through this: within each time step, forward propagate, take action, observe reward and next state, then immediately train on that transition.

  27. 27

    What preprocessing steps are applied to Atari game frames before feeding to DQN?

    Model answer

    Convert to grayscale, crop the screen (remove score and unnecessary parts), and stack a history of 4 consecutive frames to capture motion.

    Explanation

    The lecture discusses removing RGB channels, cropping, and using multiple frames to infer velocity. This preprocessing reduces dimensionality and provides temporal information.

  28. 28

    Why is a history of frames (e.g., 4 frames) used as input to DQN?

    Model answer

    A single frame does not show the direction or velocity of moving objects; stacking frames provides temporal context enabling the agent to perceive motion.

    Explanation

    In Breakout, you need to know the ball's direction. With one frame, you can't tell where it's going; with 4 frames, you can estimate velocity.

  29. 29

    How is a terminal state handled when computing the target Y in DQN?

    Model answer

    If the next state is terminal, the target Y is simply the immediate reward r, with no discounted future term.

    Explanation

    The lecture notes that for terminal states, there is no next state, so the Bellman equation reduces to just the immediate reward.

  30. 30

    What is experience replay and why is it beneficial?

    Model answer

    Experience replay stores transitions (s, a, r, s') in a replay memory; during training, a random mini-batch of transitions is sampled to update the network, reducing correlation between consecutive samples and increasing data efficiency.

    Explanation

    The lecture explains that successive frames are highly correlated, causing instability. Replay memory breaks correlation and allows reuse of rare experiences.

  31. 31

    How does experience replay reduce correlation between successive training samples?

    Model answer

    By sampling randomly from a buffer of past experiences, the training batch contains uncorrelated transitions from different episodes and time steps, rather than consecutive frames from the same episode.

    Explanation

    The lecture compares it to training on mini-batches of cats then dogs: correlated data hinders convergence. Random sampling decorrelates the data.

  32. 32

    What is the epsilon-greedy strategy for exploration?

    Model answer

    With probability ε, the agent takes a random action; with probability 1-ε, it takes the greedy action (argmax Q). This encourages exploration of less-visited states.

    Explanation

    The lecture introduces ε-greedy to avoid getting stuck in local optima, allowing the agent to discover better strategies by occasionally acting randomly.

  33. 33

    In the exploration-exploitation dilemma, why might an agent get stuck without epsilon-greedy?

    Model answer

    Without exploration, the agent always exploits its current best action; if a better action has a lower initial Q-value, it may never be tried, resulting in suboptimal policy.

    Explanation

    The lecture gives an example where initial Q-values favor a low-reward terminal state; without random actions, the agent never visits the high-reward state.

  34. 34

    What is PPO (Proximal Policy Optimization) and how does it differ from DQN?

    Model answer

    PPO is a policy-based RL algorithm that directly learns the policy (action probabilities) rather than a value function; it works well with continuous action spaces and uses a clipped surrogate objective for stable updates.

    Explanation

    DQN is value-based and outputs Q-values for discrete actions. PPO learns a stochastic policy and can handle continuous actions like joint angles in robotics.

  35. 35

    Why is the game Montezuma's Revenge particularly challenging for DQN?

    Model answer

    Rewards are very delayed (the agent must perform a long sequence of precise actions to reach a key), so random exploration rarely leads to reward, making learning extremely difficult.

    Explanation

    The lecture notes that with a random network, the chance of making all the right moves to get the key is very low, so the agent gets no reward signal to learn from.

  36. 36

    What is competitive self-play in RL?

    Model answer

    Competitive self-play involves multiple copies of the same agent playing against each other; the agents learn by competing, and the best-performing agent is copied to others, improving over time.

    Explanation

    The lecture shows sumo wrestling where agents push each other; they learn emergent strategies like lowering center of gravity. The winning agent is copied to accelerate learning.

  37. 37

    What is imitation learning and how can it help in RL?

    Model answer

    Imitation learning is learning from demonstrations by human experts, often used to initialize an agent's policy, providing a better starting point than random initialization.

    Explanation

    In Montezuma's Revenge, human intuition (knowing ladders are climbable) can be encoded via imitation learning to help the agent make initial progress. The lecture mentions using human knowledge to start the network.

  38. 38

    Name one advantage of PPO over DQN for continuous action spaces.

    Model answer

    PPO can directly output continuous actions (e.g., joint angles) via a stochastic policy, while DQN requires discretization of actions which may be impractical.

    Explanation

    The lecture contrasts DQN (discrete actions) with PPO (continuous actions) using the example of autonomous driving where turning degrees are continuous.

  39. 39

    What is supervised fine-tuning (SFT) in the context of LLMs?

    Model answer

    SFT is training a pre-trained language model on a dataset of human-written prompt-response pairs using the same next-token prediction loss, to imitate helpful behavior.

    Explanation

    The lecture describes collecting 13,000 human-written responses and fine-tuning the model on them. This teaches the model to produce helpful answers but only imitates rather than optimizes for preferences.

  40. 40

    What are two shortcomings of supervised fine-tuning (SFT)?

    Model answer
    1. It is costly to collect human-written responses. 2) It may not generalize to unseen prompts because it only imitates examples without optimizing for human preferences.

    Explanation

    The lecture mentions that SFT data is expensive and that it teaches imitation, not preference optimization, so the model may not handle new prompts well.

  41. 41

    How is a reward model trained in RLHF?

    Model answer

    A reward model is initialized from the SFT model (with final layer replaced by a scalar output) and trained on human preference data: for each pair of responses to the same prompt, it learns to assign higher reward to the preferred response using a pairwise loss.

    Explanation

    The lecture explains that labelers rank responses, and the reward model is trained to predict these preferences. The loss encourages the model to give higher scores to preferred responses.

  42. 42

    Why is it easier to collect preference data than to have humans write responses in RLHF?

    Model answer

    Asking humans to compare two responses and state a preference is faster and cheaper than asking them to write a high-quality response from scratch.

    Explanation

    The lecture notes that preference data (pairwise comparisons) is easier to collect, which is why RLHF scales better than SFT alone.

  43. 43

    In RLHF, what are the agent, environment, state, action, and reward?

    Model answer

    Agent: the language model being fine-tuned. Environment: the space of possible prompts and continuations. State: the prompt plus tokens generated so far. Action: the next token selected. Reward: the scalar output from the reward model at the end of the sequence.

    Explanation

    The lecture maps RL terminology to LLM fine-tuning. The action is picking the next token, and reward is given only after the full response is generated.

  44. 44

    Why is the reward in RLHF typically only given at the end of the sequence?

    Model answer

    The reward model is trained to evaluate entire prompt-response pairs, so it provides a reward only after the complete response is generated, not for individual tokens.

    Explanation

    The lecture states that the reward model rates prompts and responses together, so you need to finish generation to get the reward. This makes it a sparse reward episodic task.

  45. 45

    How does RLHF align language models with human preferences?

    Model answer

    RLHF uses reinforcement learning to maximize the expected reward from the reward model, which acts as a proxy for human preferences. The language model (agent) generates responses, receives a reward from the reward model, and updates its policy to produce higher-scoring responses.

    Explanation

    The lecture describes the RLHF loop: the agent (language model) generates text, the reward model scores it, and the agent uses this feedback to improve, aligning its outputs with what humans prefer.

  46. 46

    What is the role of the reward model in the RLHF loop?

    Model answer

    The reward model acts as a critic that evaluates the quality of the language model's responses according to human preferences, providing a reward signal for reinforcement learning.

    Explanation

    The lecture calls the reward model a 'critic' or 'proxy for human preferences.' It is used to score responses during RL training, guiding the language model to produce more preferred outputs.

1 of 46
Question 1 of 46

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent