Value Functions and Q Functions
- 25Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What does the Q-function Qπ(s,a) represent?
What does the Q-function Qπ(s,a) represent?
25 questions
- 1
What does the Q-function Qπ(s,a) represent?
- A
The total discounted future reward starting from state s, taking action a, and following policy π thereafter
- B
The probability of taking action a in state s under policy π
- C
The immediate reward for taking action a in state s
- D
The difference between the value of state s and the value of the next state
Correct answer
AThe total discounted future reward starting from state s, taking action a, and following policy π thereafter
Explanation
The Q-function is defined as the expected sum of discounted future rewards starting from state s, taking action a, and then following policy π.
- A
- 2
Which equation is known as the Bellman equation for the Q-function?
- A
Qπ(s,a)=r(s,a)+γEs′[Qπ(s′,π(s′))]
- B
Qπ(s,a)=Es′[r(s,a)+γVπ(s′)]
- C
Qπ(s,a)=maxa′Es′[r(s,a)+γQπ(s′,a′)]
- D
Qπ(s,a)=r(s,a)+γEs′[maxa′Qπ(s′,a′)]
Correct answer
AQπ(s,a)=r(s,a)+γEs′[Qπ(s′,π(s′))]
Explanation
The Bellman equation expresses the Q-function recursively: the current Q equals the immediate reward plus the discounted expected Q of the next state-action pair under the policy.
- A
- 3
The Bellman optimality equation for the optimal Q-function Q∗ is:
- A
Q∗(s,a)=maxa′(r(s,a)+γEs′[Q∗(s′,a′)])
- B
Q∗(s,a)=r(s,a)+γEs′[maxa′Q∗(s′,a′)]
- C
Q∗(s,a)=Es′[r(s,a)+γmaxa′Q∗(s′,a′)]
- D
Q∗(s,a)=r(s,a)+γEs′[Q∗(s′,π∗(s′))]
Correct answer
BQ∗(s,a)=r(s,a)+γEs′[maxa′Q∗(s′,a′)]
Explanation
The Bellman optimality equation for Q-function states that the optimal Q-value equals the immediate reward plus the discounted expected maximum Q-value over next actions.
- A
- 4
In policy iteration, what is the policy improvement step?
- A
Setting the policy to be a random policy to encourage exploration
- B
Sampling actions from the current policy and averaging their Q-values
- C
Updating the policy by taking a gradient step on the policy parameters
- D
Defining a new deterministic policy that takes the action maximizing the current Q-function
Correct answer
DDefining a new deterministic policy that takes the action maximizing the current Q-function
Explanation
Policy improvement sets π′(s)=argmaxaQπ(s,a), which yields a policy at least as good as the original.
- A
- 5
Given a policy π, if we define π′(s)=argmaxaQπ(s,a), which of the following is true?
- A
π′ is always the optimal policy
- B
π′ is guaranteed to be at least as good as π
- C
π′ is always a stochastic policy
- D
π′ is worse than π if the Q-function is inaccurate
Correct answer
Bπ′ is guaranteed to be at least as good as π
Explanation
The policy improvement theorem guarantees that π′ is at least as good as π, and strictly better if π is not already optimal.
- A
- 6
In the grid example from the lecture, starting with a policy that always goes right, after one policy improvement step, why does the new policy not reach the star from all starting positions?
- A
Because the Q-function is inaccurate
- B
Because the new policy is stochastic and sometimes chooses suboptimal actions
- C
Because the discount factor is zero
- D
Because the new policy only improves for states where Q-values for 'go up' are higher than 'go right', which occurs only in certain rows
Correct answer
DBecause the new policy only improves for states where Q-values for 'go up' are higher than 'go right', which occurs only in certain rows
Explanation
The new policy improves only for states where the Q-value for 'up' is higher than for 'right'. In the bottom row, all Q-values are zero, so the policy defaults to the old behavior (going right).
- A
- 7
What is the main difference between the Bellman equation and the Bellman optimality equation?
- A
The Bellman equation is for value functions, while the optimality equation is for Q-functions
- B
The Bellman equation uses an expectation over actions, while the optimality equation uses a maximization
- C
The Bellman equation includes a discount factor, while the optimality equation does not
- D
The Bellman equation holds for any policy, while the optimality equation holds only for the optimal policy
Correct answer
BThe Bellman equation uses an expectation over actions, while the optimality equation uses a maximization
Explanation
The Bellman equation for a given policy uses the expectation under that policy, while the Bellman optimality equation uses the max over actions, reflecting the optimal policy's behavior.
- A
- 8
Q-learning is an off-policy algorithm because:
- A
It uses a replay buffer that stores transitions from past policies
- B
It learns the optimal Q-function independently of the policy used to collect data
- C
It requires data from the current policy only
- D
It uses importance sampling to correct for policy mismatch
Correct answer
AIt uses a replay buffer that stores transitions from past policies
Explanation
Q-learning is off-policy because it can learn from transitions generated by any behavior policy, not necessarily the current policy being evaluated.
- A
- 9
In Q-learning, the target value for updating the Q-function is:
- A
r+γEa′∼π[Q(s′,a′)]
- B
r+γmina′Q(s′,a′)
- C
r+γV(s′)
- D
r+γmaxa′Q(s′,a′)
Correct answer
Dr+γmaxa′Q(s′,a′)
Explanation
The Q-learning target is r+γmaxa′Q(s′,a′), which uses the max over next actions to bootstrap towards the optimal Q-function.
- A
- 10
Under what conditions is tabular Q-learning guaranteed to converge to the optimal Q-function?
- A
When the state space is small and function approximation is used
- B
When the policy is deterministic
- C
When the learning rate decays appropriately and all state-action pairs are visited infinitely often
- D
When the reward function is sparse
Correct answer
CWhen the learning rate decays appropriately and all state-action pairs are visited infinitely often
Explanation
Tabular Q-learning converges to the optimal Q-function if each state-action pair is visited infinitely often and the learning rate satisfies the Robbins-Monro conditions.
- A
- 11
Why does Q-learning with neural networks often require a replay buffer?
- A
To break the correlation between consecutive samples and improve data efficiency
- B
To compute the target values more quickly
- C
To ensure that the data is generated by the current policy
- D
To reduce memory usage
Correct answer
ATo break the correlation between consecutive samples and improve data efficiency
Explanation
The replay buffer stores past transitions and allows sampling mini-batches uniformly, which decorrelates the data and makes training more stable and efficient.
- A
- 12
Which of the following is an advantage of using an epsilon-greedy policy for exploration in Q-learning?
- A
It provides good coverage of actions while mostly following the greedy policy
- B
It guarantees that the optimal policy is found in one iteration
- C
It eliminates the need for a replay buffer
- D
It ensures that all actions are selected with equal probability over time
Correct answer
AIt provides good coverage of actions while mostly following the greedy policy
Explanation
Epsilon-greedy selects random actions with small probability ϵ, ensuring exploration of all actions while mostly exploiting the current best action.
- A
- 13
In Boltzmann exploration, the probability of selecting an action is proportional to:
- A
exp(−Q(s,a))
- B
Q(s,a)1
- C
Q(s,a)
- D
exp(Q(s,a))
Correct answer
Dexp(Q(s,a))
Explanation
Boltzmann exploration uses a softmax distribution: P(a∣s)∝exp(Q(s,a)/τ), where τ is the temperature parameter.
- A
- 14
Why is it important to use an exploration policy that covers many actions in Q-learning?
- A
Because the policy is deterministic and needs diverse data
- B
Because the target uses a max over actions, and Q-values for unseen actions may be inaccurate
- C
Because the replay buffer requires diverse transitions
- D
Because the Q-function is initialized to zero
Correct answer
BBecause the target uses a max over actions, and Q-values for unseen actions may be inaccurate
Explanation
The max over actions in the target uses Q-values for all actions. If an action has not been tried, its Q-value may be erroneously high or low, leading to inaccurate targets.
- A
- 15
What is the main purpose of using a target network in DQN?
- A
To make the learning targets stationary and stabilize training
- B
To allow parallel computation
- C
To increase the exploration rate
- D
To reduce the number of parameters
Correct answer
ATo make the learning targets stationary and stabilize training
Explanation
A target network is a frozen copy of the Q-network used to compute targets. Updating it periodically keeps targets stable, preventing moving-target issues that cause divergence.
- A
- 16
In the original DQN algorithm, how often is the target network updated?
- A
Never; it is fixed after initial training
- B
Every fixed number of gradient steps (e.g., every 100 steps)
- C
Every episode
- D
Every gradient step
Correct answer
BEvery fixed number of gradient steps (e.g., every 100 steps)
Explanation
The target network is updated periodically (e.g., every 10,000 steps in Atari) to match the current network, reducing the frequency of target changes.
- A
- 17
What problem does Double DQN address?
- A
Overestimation of Q-values due to the max operation
- B
Slow convergence
- C
Underestimation of Q-values
- D
High variance in gradient estimates
Correct answer
AOverestimation of Q-values due to the max operation
Explanation
Standard Q-learning tends to overestimate Q-values because the max operation selects actions with noisy high estimates. Double DQN reduces this by using separate networks for action selection and evaluation.
- A
- 18
In Double DQN, how is the target computed?
- A
r+γEa′∼π[Q(s′,a′;θ)]
- B
r+γQ(s′,argmaxa′Q(s′,a′;θ);θ−)
- C
r+γmaxa′Q(s′,a′;θ−)
- D
r+γQ(s′,argmaxa′Q(s′,a′;θ−);θ)
Correct answer
Br+γQ(s′,argmaxa′Q(s′,a′;θ);θ−)
Explanation
Double DQN uses the current network θ to select the best action, and the target network θ− to evaluate it: y=r+γQ(s′,argmaxa′Q(s′,a′;θ);θ−).
- A
- 19
What is a potential drawback of using n-step returns in Q-learning?
- A
It increases variance more than bias
- B
The rewards in the n-step return come from the behavior policy, not the optimal policy, introducing bias
- C
It requires a separate neural network for each n
- D
It is computationally expensive
Correct answer
BThe rewards in the n-step return come from the behavior policy, not the optimal policy, introducing bias
Explanation
N-step returns use actual rewards from the replay buffer, which were generated by the behavior policy. This introduces bias because the rewards may not reflect the optimal policy.
- A
- 20
According to the lecture, which algorithm is recommended for discrete action spaces with high data efficiency?
- A
Soft Actor-Critic
- B
Policy Gradient
- C
DQN
- D
PPO
Correct answer
CDQN
Explanation
DQN works well with discrete actions and can be data-efficient when combined with techniques like replay buffers and target networks.
- A
- 21
Which of the following statements about Q-learning is true?
- A
Q-learning cannot use function approximation
- B
Q-learning is an on-policy algorithm
- C
Q-learning directly learns the optimal policy without a separate policy network
- D
Q-learning requires a policy network to output action probabilities
Correct answer
CQ-learning directly learns the optimal policy without a separate policy network
Explanation
Q-learning learns the optimal Q-function, from which the optimal policy can be derived by taking the argmax over actions. It does not require an explicit policy network.
- A
- 22
In the context of Q-learning, what does 'bootstrapping' refer to?
- A
Using Monte Carlo returns
- B
Using a separate target network
- C
Using importance sampling
- D
Using the current estimate of Q to update itself
Correct answer
DUsing the current estimate of Q to update itself
Explanation
Bootstrapping means updating the Q-value using a target that includes the current estimate of future Q-values, as in the Q-learning target r+γmaxa′Q(s′,a′).
- A
- 23
Why might the loss function for Q-learning increase over time even as the policy improves?
- A
Because the target network is not updated
- B
Because the replay buffer is too small
- C
Because the Q-values become larger in magnitude, increasing the scale of the loss
- D
Because the learning rate is too high
Correct answer
CBecause the Q-values become larger in magnitude, increasing the scale of the loss
Explanation
As the policy improves, Q-values increase (since they represent expected returns), which increases the squared error loss. This is normal and does not indicate failure.
- A
- 24
Which of the following is a common way to combine Double DQN with a target network?
- A
Use the target network for both action selection and evaluation
- B
Use the target network for action selection and the current network for evaluation
- C
Use the current network for action selection and the target network for evaluation
- D
Use two separate target networks
Correct answer
CUse the current network for action selection and the target network for evaluation
Explanation
Double DQN typically uses the current network to select the action (argmax) and the target network to evaluate its Q-value, reducing overestimation.
- A
- 25
What is a key difference between on-policy and off-policy reinforcement learning?
- A
On-policy methods learn from data generated by the current policy, while off-policy methods can use data from any policy
- B
Off-policy methods cannot use replay buffers
- C
On-policy methods are only applicable to discrete actions
- D
On-policy methods are always more sample efficient
Correct answer
AOn-policy methods learn from data generated by the current policy, while off-policy methods can use data from any policy
Explanation
On-policy methods require data from the current policy, whereas off-policy methods can learn from data generated by any policy, making them more sample efficient.
- A

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