1. Home
  2. Explore
  3. Computer Science
  4. Value Functions and Q Functions

Study methods

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

Value Functions and Q Functions

  • 16Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Value Functions and Policy

What is the definition of the Q function Qπ(s,a)Q^\pi(s,a)Qπ(s,a)?

16 questions

  1. 1

    What is the definition of the Q function Qπ(s,a)Q^\pi(s,a)Qπ(s,a)?

    Model answer

    Qπ(s,a)Q^\pi(s,a)Qπ(s,a) is the expected sum of future rewards starting from state sss, taking action aaa, and then following policy π\piπ thereafter.

    Explanation

    The Q function represents the expected return from state-action pair (s,a)(s,a)(s,a) under policy π\piπ.

  2. 2

    How does policy improvement work when you have an accurate Q function?

    Model answer

    Define a new deterministic policy by taking the action that maximizes Q(s,a)Q(s,a)Q(s,a) at each state: π′(s)=arg⁡max⁡aQπ(s,a)\pi'(s) = \arg\max_a Q^{\pi}(s,a)π′(s)=argmaxa​Qπ(s,a). This new policy is at least as good as the original policy π\piπ.

    Explanation

    By choosing the action with highest Q-value, the expected return from each state is at least as large as under π\piπ, so π′\pi'π′ is a policy improvement.

  3. 3

    In the 2D navigation example with a policy that always goes right, why is the new policy from arg⁡max⁡Q\arg\max QargmaxQ better than the old policy but not optimal?

    Model answer

    The new policy goes up in the row where Q for 'up' is 1, but in the initial row, all Q-values are 0, so it defaults to right and never reaches the star. Thus it improves locally but not globally.

    Explanation

    The Q-function for the old policy only 'backs up' reward one step; iterating improvement would eventually yield optimality.

  4. 4

    State the Bellman equation for the Q function of a policy π\piπ.

    Model answer

    Qπ(s,a)=r(s,a)+γEs′∼P,a′∼π[Qπ(s′,a′)]Q^\pi(s,a) = r(s,a) + \gamma \mathbb{E}_{s' \sim P, a' \sim \pi}[Q^\pi(s',a')]Qπ(s,a)=r(s,a)+γEs′∼P,a′∼π​[Qπ(s′,a′)].

    Explanation

    This recursive relationship expresses the Q-value in terms of immediate reward and discounted future Q-values under policy π\piπ.

  5. 5

    State the Bellman optimality equation for the optimal Q function Q∗Q^*Q∗.

    Model answer

    Q∗(s,a)=r(s,a)+γEs′[max⁡a′Q∗(s′,a′)]Q^*(s,a) = r(s,a) + \gamma \mathbb{E}_{s'}[\max_{a'} Q^*(s',a')]Q∗(s,a)=r(s,a)+γEs′​[maxa′​Q∗(s′,a′)].

    Explanation

    For the optimal policy, the future Q-value is maximized over actions, leading to this equation that characterizes Q∗Q^*Q∗.

  6. 6

    What is the Q-learning update rule for a transition (s,a,r,s′)(s,a,r,s')(s,a,r,s′)?

    Model answer

    Q(s,a)←Q(s,a)+α[r+γmax⁡a′Q(s′,a′)−Q(s,a)]Q(s,a) \leftarrow Q(s,a) + \alpha [r + \gamma \max_{a'} Q(s',a') - Q(s,a)]Q(s,a)←Q(s,a)+α[r+γmaxa′​Q(s′,a′)−Q(s,a)].

    Explanation

    Q-learning uses the temporal difference target r+γmax⁡a′Q(s′,a′)r + \gamma \max_{a'} Q(s',a')r+γmaxa′​Q(s′,a′) to update the Q-value towards the optimal Q-function.

  7. 7

    Explain why Q-learning is considered an off-policy algorithm.

    Model answer

    Q-learning updates the Q-function using transitions regardless of which policy generated them, and the target uses the max over actions, not the current policy's action.

    Explanation

    The update does not depend on the behavior policy; it directly approximates the optimal Q-function, making it off-policy.

  8. 8

    Under what conditions is Q-learning guaranteed to converge to the optimal Q-function?

    Model answer

    When the state and action spaces are discrete and small enough to maintain a table, and all state-action pairs are visited infinitely often with sufficient exploration.

    Explanation

    In the tabular setting with full coverage, Q-learning converges to Q∗Q^*Q∗. With function approximation, it may diverge.

  9. 9

    Why do we use a replay buffer in DQN?

    Model answer

    To store past transitions and sample them uniformly, breaking the temporal correlation in the data and making training more stable.

    Explanation

    Sampling i.i.d. from a replay buffer decorrelates the data, which is essential for neural network training.

  10. 10

    Describe the epsilon-greedy exploration strategy.

    Model answer

    With probability ϵ\epsilonϵ take a random action, and with probability 1−ϵ1-\epsilon1−ϵ take the greedy action (the one with highest Q-value).

    Explanation

    Epsilon-greedy ensures the agent explores occasionally while mostly exploiting its current knowledge.

  11. 11

    What is Boltzmann exploration?

    Model answer

    Select actions with probability proportional to exp⁡(Q(s,a)/τ)\exp(Q(s,a)/\tau)exp(Q(s,a)/τ), where τ\tauτ is a temperature parameter controlling randomness.

    Explanation

    Higher Q-values get higher probability; as τ→0\tau \to 0τ→0, it becomes greedy; as τ→∞\tau \to \inftyτ→∞, it becomes uniform.

  12. 12

    Why does the target network in DQN help stabilize learning?

    Model answer

    It freezes the target Q-values for a fixed number of updates, making the learning target stationary and reducing harmful feedback loops.

    Explanation

    Without a target network, the target changes every step, causing a moving target problem that can lead to divergence.

  13. 13

    What is the overestimation problem in Q-learning and how does double DQN address it?

    Model answer

    The max operator in the target can cause overestimation when Q-values are noisy. Double DQN uses one network to select the action and a second (target) network to evaluate it.

    Explanation

    By decoupling selection and evaluation, the noise is decorrelated, reducing overestimation bias.

  14. 14

    What is the n-step return target for Q-learning and what is its main trade-off?

    Model answer

    The target is ∑i=0n−1γirt+i+γnmax⁡a′Q(st+n,a′)\sum_{i=0}^{n-1} \gamma^i r_{t+i} + \gamma^n \max_{a'} Q(s_{t+n}, a')∑i=0n−1​γirt+i​+γnmaxa′​Q(st+n​,a′). It has lower bias early in training (relying on actual rewards) but higher variance and off-policy bias.

    Explanation

    N-step returns accelerate learning but the reward sequence may come from a different policy, introducing bias.

  15. 15

    Give two successful applications of DQN mentioned in the lecture.

    Model answer

    Playing Atari games at human-level or above, and training a robot grasping system with continuous actions.

    Explanation

    DQN achieved high performance on many Atari games and a 96% success rate on a robotic grasping task.

  16. 16

    Compare PPO and DQN in terms of data efficiency and stability.

    Model answer

    PPO is stable and easy to tune but data-inefficient. DQN is more data-efficient but less stable and best for discrete or low-dimensional action spaces.

    Explanation

    PPO is on-policy and sample-inefficient; DQN is off-policy and can reuse data, but requires tricks like target networks for stability.

1 of 16
Question 1 of 16

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent