# Entropy of policy network's output

**URL:** <https://discuss.ray.io/t/entropy-of-policy-networks-output/1163>\
**Category:** RLlib\
**Created:** [March 8, 2021, 8:50am UTC](https://discuss.ray.io/t/entropy-of-policy-networks-output/1163 "2021-03-08T08:50:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lauritowal](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/lauritowal/32/572_2.png) [@Lauritowal](https://discuss.ray.io/u/Lauritowal)\
**Post date:** [March 8, 2021, 8:50am UTC](https://discuss.ray.io/t/entropy-of-policy-networks-output/1163/1 "2021-03-08T08:50:46Z")

</div>

Hi!  
How can I display the entropy of the policy network’s outputs,  
relative to the maximum possible entropy in Tensorboard?

---

<div class="post-metadata">

**Author:** ![Ameer\_Haj\_Ali](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/ameer_haj_ali/32/279_2.png) [@Ameer\_Haj\_Ali](https://discuss.ray.io/u/Ameer_Haj_Ali)\
**Post date:** [March 10, 2021, 9:35pm UTC](https://discuss.ray.io/t/entropy-of-policy-networks-output/1163/2 "2021-03-10T21:35:23Z")

</div>

CC @rliaw . Can you please help?

---

<div class="post-metadata">

**Author:** ![rliaw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/rliaw/32/24_2.png) [@rliaw](https://discuss.ray.io/u/rliaw)\
**Post date:** [March 10, 2021, 9:53pm UTC](https://discuss.ray.io/t/entropy-of-policy-networks-output/1163/3 "2021-03-10T21:53:12Z")

</div>

@sven1977 is the right person to answer this question!

---

<div class="post-metadata">

**Author:** ![sven1977](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sven1977/32/53_2.png) [@sven1977](https://discuss.ray.io/u/sven1977)\
**Post date:** [March 11, 2021, 7:40am UTC](https://discuss.ray.io/t/entropy-of-policy-networks-output/1163/4 "2021-03-11T07:40:43Z")

</div>

Hey @Lauritowal , you can specify a custom callback to calculate this property and store it for TB displaying.

Like so:

1. Check out the example script rllib/examples/custom\_metrics\_and\_callbacks.py
2. Override `on_postprocess_trajectory` and take a look at the `postprocessed_batch` arg therein. You should be able to see “ACTION\_PROBS” and “ACTION\_LOGP” as keys. You could use them to calculate the entropy.
3. Store that entropy inside e.g. `episode.custom_metrics["policy_entropy"]`.
4. You should see these values now in TB.
