Q-Learning

2 min read

Q-learning is an off-policy TD control algorithm that directly learns the optimal action-value function QQ^*.

Update rule:

Q(St,At)Q(St,At)+α[Rt+1+γmaxaQ(St+1,a)Q(St,At)]Q(S_t, A_t) \leftarrow Q(S_t, A_t) + \alpha\left[R_{t+1} + \gamma \max_{a'} Q(S_{t+1}, a') - Q(S_t, A_t)\right]

Off-policy: the maxa\max_{a'} means we update toward the best possible action, regardless of what action the behavior policy actually took. The agent can explore (e.g., ϵ\epsilon-greedy) while learning the optimal policy.

Algorithm (tabular):

  1. Initialize Q(s,a)Q(s,a) arbitrarily
  2. For each step: observe StS_t, take action AtA_t (e.g., ϵ\epsilon-greedy), observe Rt+1,St+1R_{t+1}, S_{t+1}
  3. Apply the update rule above
  4. Converges to QQ^* given sufficient exploration and decaying learning rate

ϵ\epsilon-greedy exploration:

  • With probability ϵ\epsilon: random action (explore)
  • With probability 1ϵ1-\epsilon: greedy action argmaxaQ(s,a)\arg\max_a Q(s,a) (exploit)
  • Decay ϵ\epsilon over time for convergence

Convergence: guaranteed to converge to QQ^* in the tabular case under standard conditions (all state-action pairs visited infinitely often, learning rate decays appropriately).

Scaling up: tabular Q-learning fails for large/continuous state spaces → Deep Q-Network uses a neural network to approximate QQ.

See also: SARSA, Miscoral Difference Learning, Deep Q-Network

Linked from