Entropy-Regularized Reinforcement Learning
Topics: Reinforcement Learning
Entropy in General
Entropy is a measure of the randomness or uncertainty of a probability distribution.
Let be a random variable with probability mass or probability density function . The entropy of is defined as (1):
So, for a discrete random variable , the entropy is:
And for a continuous random variable , the entropy is:
Entropy in RL
In the case of the RL problem, the policy defines the probability of taking action in state ; so, the policy is a probability distribution. Thus, entropy in RL is a measure of the randomness of the policy: the more random a policy is, the higher its entropy. A high entropy policy means that the agent takes varied actions, and thus, explores more. On the other hand, a low entropy policy means that the agent takes more predictable actions, which corresponds to lower exploration and higher exploitation.
The equation for the entropy of the policy is written as follows:
The figure below compares a low entropy policy (left) to a high entropy policy (right) in a discrete action space (2).

The low entropy policy is almost deterministic, while the high entropy policy is highly stochastic.
Entropy-Regularized RL
In the Entropy-Regularized RL environment, entropy is used as an entropy bonus that gets added to the reward function. This is done for every time step, meaning that present actions also play a role in maximizing future entropy (2). The finite horizon discounted return in entropy-regularized RL is:
The entropy bonus can be seen as a regular reward term which encourages exploration. It can be controlled by , known as the entropy regularization coefficient.
If the entropy of the policy is large, and therefore the entropy bonus is large, while the original reward term is low, this means that little is known about the impact of different actions and more exploration is needed.
Also, in stochastic policy, action probabilities are proportional to their expected rewards. So, if entropy is very large relative to the rewards, then action probabilities are more or less equal, whereas if the entropy is small relative to the rewards, then the rewards are received from more defining action probabilities.
The optimal policy of the Entropy-Regularized RL problem becomes (1):
The value function is also changed to include the entropy bonuses from every timestep:
V^{\pi}(s) = \underset{\tau \sim \pi}{E} \Biggl[ \sum_{t=0}^\infty \gamma^{t} \biggl( R(s_t, a_t, s_{t+1}) + \alpha H \Bigl( \pi( \cdot \vert s_t) \Bigr) \biggr) \Bigg{\vert} s_{0} = s \Biggr]
The action value function is changed to include the entropy bonuses from every timestep except the first:
Q^{\pi}(s,a) = \underset{\tau \sim \pi}{E} \Bigg[ \sum_{t=0}^\infty \gamma^{t} \; R(s_t, a_t, s_{t+1}) + \alpha \sum_{t=1}^{\infty} \gamma^{t} H \Big( \pi( \cdot \vert s_t) \Big) \Bigg{\vert} s_{0} = s, \; a_0=a \Bigg]
The definitions of and are connected by:
And the Bellman Equation for is:
\begin{align*} & Q^{\pi}(s,a) = \underset{\substack{s' \sim P \\ \\ a' \sim \pi}}{E} \Bigg[ R(s, a, s') + \gamma \, \bigg( Q^{\pi}(s',a') + \alpha \, H \Big( \pi( \cdot \vert s_t) \Big) \bigg) \Bigg] \\ \\ & \quad\quad\quad\;\;\; = \underset{s' \sim P}{E} \bigg[ R(s,a,s') + \gamma \, V^{\pi}(s') \bigg] \end{align*}$$ ## Note The way we’ve set up the value functions in the entropy-regularized setting is a little bit arbitrary, and actually we could have done it differently (for example include the first entropy bonus in $Q^{\pi}$. The choice of definition may vary slightly across papers on the subject. ## References 1. https://spinningup.openai.com/en/latest/algorithms/sac.html#entropy-regularized-reinforcement-learning 2. https://towardsdatascience.com/entropy-regularized-reinforcement-learning-explained-2ba959c92aad/Backlinks
Notes that reference this page.
Connections
Direct relationships to this note.