Skip to Content
Reinforcement Learning
book

Reinforcement Learning

by Phil Winder
November 2020
Intermediate to advanced
408 pages
11h 49m
English
O'Reilly Media, Inc.
Content preview from Reinforcement Learning

Appendix A. The Gradient of a Logistic Policy for Two Actions

Equation 5-6 is a policy for two actions. To update the policies I need to calculate the gradient of the natural logarithm of the policy (see Equation 5-4). I present this in Equation A-1. You can perform the differentiation in a few different ways depending on how you refactor it, so the result can look different, even though it provides the same result.

Equation A-1. Logistic policy gradient for two actions
lnπ(as,θ)=(δδθ0ln(11+eθ0s)δδθ1ln(111+eθ1s))

I calculate the gradients of each action independently and I find it easier if I refactor the logistic function like in Equation A-2.

Equation A-2. Refactoring the logistic function
π(x)11+ex=exex(1+ex)=exex(1+ex)=exex+exex=exex+exx=exex+e0=exex+1=ex1+ex

The derivative of the refactored logistic function, for action 0, is shown in Equation A-3.

Equation A-3. Differentiation of action 0
δδθ0lnπ0(θ0s)=δδθ0ln(eθ0s1+eθ0s)=δδθ0lneθ0sδδθ0ln(1+eθ0s)=δδθ0θ0sδδθ0ln(1+eθ0s)=sδδθ0ln(1+eθ0s)=sδδθ0lnuwhere u=1+eθ0s=s1uδδθ0u=s11+eθ0sδδθ0(1+eθ0s)=s11+eθ0sδδv(ev)δδθ0vwhere v=θ0s=s11+eθ0seθ0ss=sseθ0s1+eθ0s=ssπ(θ0s)

The method to calculate the derivative of the policy for action 1 is shown in Equation A-4. Note that the derivation towards the end is the same as Equation A-3.

Equation A-4. Differentiation of action 1
δδθ1lnπ1(θ1s)=δδθ1ln(1eθ1s1+eθ1s)=δδθ1ln(1+eθ1s1+eθ1seθ1s1+eθ1s)=δδθ1ln(1+eθ1seθ1s1+eθ1s)=δδθ1ln(11+eθ1s)=δδ
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Grokking Deep Reinforcement Learning

Grokking Deep Reinforcement Learning

Miguel Morales
Deep Reinforcement Learning in Action

Deep Reinforcement Learning in Action

Alexander Zai, Brandon Brown

Publisher Resources

ISBN: 9781492072386Errata Page