Maximum Entropy RL
Score the goal and the spread. The policy keeps every good path alive in proportion to its value instead of collapsing to one narrow line.
Why Does This Exist?
Plain RL maxes expected reward:
That push collapses to one deterministic pick. Spread hits zero, backup routes vanish, and a small gust or slip breaks the run. Tasks with two equal doors keep only one.
Max entropy RL from Ziebart plus Haarnoja and Levine adds spread to the goal. Each step pays reward plus times entropy . Policies stay smooth and multimodal, with weight on every viable path. This page covers the objective and the soft values. The actor critic built on it lives in soft actor-critic. The tabular value form lives in soft Q-learning. Plain gradients live in policy gradient.
The one idea you need first
Entropy measures spread: . Uniform is high, single spike is zero. Temperature prices spread in reward units. Near zero recovers plain RL. Large values wander.
Think of It Like This
One ridge trail versus a mapped valley
A plain explorer finds one narrow ridge over a ravine and declares it the only route. All traffic walks single file. One fallen rock strands the party.
An entropy surveyor maps ridge, river path, and forest track, then splits traffic by safety and speed. A blocked ridge shifts walkers to the river with no panic.
Where it stops: hikers pick one path per trip. A MaxEnt policy is a full spread over actions at once, hedging every step instead of booking one trail.
How It Actually Works
Objective with temperature :
Hard max turns soft:
Action values still back up reward plus next soft value:
Optimal policy is Boltzmann, in words exponentiated value over its sum:
with . Better actions get exponentially more chance, weaker ones keep nonzero mass. As drops to zero the soft value returns to hard max.
Worked example
One state, two actions, , . Rewards give .
Partition:
Chances:
Sum is . Entropy in nats:
Mean reward:
Total objective:
Soft value check:
Matches to four places. Plain max would pay on one spike. Soft pays because it counts reward plus spread. Those are the numbers the diagram draws.
Code
This snippet uses only the standard library and prints the same partition, chances, entropy, mean, objective, and soft value.
import math
q1 = 2.0q2 = 1.0alpha = 1.0e1 = math.exp(q1 / alpha)e2 = math.exp(q2 / alpha)z = e1 + e2print(round(z, 4)) # -> 10.1073p1 = e1 / zp2 = e2 / zprint([round(p1, 4), round(p2, 4)]) # -> [0.7311, 0.2689]h = -(p1 * math.log(p1) + p2 * math.log(p2))print(round(h, 4)) # -> 0.5822mean = p1 * q1 + p2 * q2print(round(mean, 4)) # -> 1.7311print(round(mean + alpha * h, 4)) # -> 2.3133print(round(alpha * math.log(z), 4)) # -> 2.3132Soft value matches objective up to rounding, which is the identity the page claims.
Watch Out For
Leaving temperature fixed for the whole run
One cannot serve early roaming and late control. High drowns reward in noise and walks at random. Low collapses early to one spike and keeps plain RL flaws. A single static value picks one failure.
Track spread and move against a target. In soft actor-critic style tuning, raise when entropy falls below target and lower it when entropy runs hot. Log , entropy, and mean reward together.
Reading soft value as plain best value
at tops plain max because it adds spread value. Treating it as achievable reward overstates the policy and breaks comparisons with hard backups.
Label soft and hard separately. Compare policies by sampled mean reward plus measured entropy, not by soft value alone. Convert only when is near zero.
The Quick Version
- Objective is reward plus times entropy at every step.
- Hard max turns into log sum exp with temperature .
- Optimal policy is Boltzmann: chance proportional to .
- Worked numbers: , chances and , entropy .
- Soft value matches mean plus entropy .