Skip to content

Commit 19a36b2

Browse files
committed
Fix incorrect description of update implementation
1 parent b1b8a97 commit 19a36b2

1 file changed

Lines changed: 28 additions & 10 deletions

File tree

report/report.tex

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,25 @@
9696
Approximation allows tight control of the amount of memory being used to represent the value function. Because of the complex update step however, only at most half of the memory can be used for storing weights. Even then, the update step must be implemented carefully to control the stack size. Consider the episodic semi-gradient one-step Sarsa update:
9797

9898
\begin{equation}\label{eqn:update}
99-
\bm{\theta}_{t+1} = \bm{\theta}_t + \alpha \Big[R_{t+1} + \gamma \hat{q}(S_{t+1}, A_{t+1}\, \bm{\theta}_t) - \hat{q}(S_t, A_t, \bm{\theta}_t)\Big]\Delta\hat{q}(S_t, A_t, \bm{\theta}_t)\tag{1}
99+
\bm{\theta}_{t+1} =
100+
\bm{\theta}_t +
101+
\alpha \Big[
102+
R_{t+1} +
103+
\gamma \hat{q}(S_{t+1}, A_{t+1}\, \bm{\theta}_t)
104+
- \hat{q}(S_t, A_t, \bm{\theta}_t)
105+
\Big]
106+
\Delta\hat{q}(S_t, A_t, \bm{\theta}_t)\tag{1}
107+
\end{equation}
108+
109+
And in the linear case:
110+
111+
\begin{equation}\label{eqn:linear_update}
112+
\bm{\theta}_{t+1} =
113+
\bm{\theta}_t +
114+
\alpha \Big[
115+
R_{t+1} + \gamma\, \bm{\theta}_t^\top\bm{\phi}_{t+1} \space
116+
- \bm{\theta}_t^\top\bm{\phi}_t
117+
\Big]\bm{\phi}_t\tag{2}
100118
\end{equation}
101119

102120
It is possible to implement the update using only $n$ additional space, where $n$ is the number of weights, but this is easy to do incorrectly. If the action selection step is placed after the memory allocation, the stack will consume $2n$ memory; maximizing the value function over possible next states requires an additional $n$ stack space.
@@ -105,16 +123,16 @@
105123
\caption{Memory-conscious Episodic Semi-gradient One-step Sarsa}
106124
\label{alg:update}
107125
\begin{algorithmic}[1] % The number tells where the line numbering should start
108-
\Procedure{Update}{$S_t$, $A_t$, $S_{t+1}$, $\theta$}
126+
\Procedure{Update}{$S_t$, $A_t$, $S_{t+1}$, \bm{$\theta$}}
109127
\State $A_{t+1} \gets $ choose action from $S_{t+1}$ according to policy
110-
\State Allocate $x$ to be a vector the size of $\theta$, and floats $r$ and $b$
128+
\State Allocate \bm{$x$} to be a vector the size of \bm{$\theta$}, and floats $r$ and $a$
111129
\State $r\gets r(S_t$, $A_t$, $S_{t+1}$)
112-
\State $x \gets \phi(S_t, A_t)$ \Comment store $\phi_{t}$
113-
\State $b \gets \theta^\top \phi'$ \Comment calculate $v(S_{t+1},A_{t+1})$ so we can discared $\phi_{t}$
114-
\State $x \gets \phi(S_{t+1}, A_{t+1})$ \Comment store $\phi_{t+1}$
115-
\State $error \gets r + \gamma b - \theta^\top x$ \Comment $error$ is now the bracketed term in eq. $\ref{eqn:update}$
116-
\State $x \gets (\alpha error)x$ \Comment $x$ is now the right side of the addition in eq. $\ref{eqn:update}$
117-
\State $\theta \gets \theta + x$
130+
\State $\bm{x} \gets \phi(S_{t+1}, A_{t+1})$ \Comment store $\phi_{t+1}$
131+
\State $a \gets \bm{\theta}^\top \bm{x}$ \Comment calculate $v(S_{t+1},A_{t+1})$ so we can discard $\phi_{t+1}$
132+
\State $\bm{x} \gets \phi(S_{t}, A_{t})$ \Comment store $\phi_t$
133+
\State $a \gets r + \gamma v - \bm{\theta}^\top \bm{x}$ \Comment $a$ is now the bracketed term in eq. $\ref{eqn:update}$
134+
\State $\bm{x} \gets (\alpha \space a)\bm{x}$ \Comment $\bm{x}$ is now the TD error
135+
\State \bm{$\theta} \gets \bm{\theta} + x$
118136
\
119137
\EndProcedure
120138
\end{algorithmic}
@@ -132,7 +150,7 @@
132150
\section{Experimental Setup}
133151

134152

135-
The agent learns for 50 episodes using $\alpha =$ 0.2, $\gamma =$ 0.99, following an $\epsilon$-greedy policy with $\epsilon=$0.1. Then, the agent operates in an evaluation mode for 50 episodes with $\alpha=\epsilon=0.0$. During this period, episodes are limited to 200 steps in case the agent executes a policy that never reaches the goal. A small delay is used between action execution and sensing to allow the arm to settle. The photocell threshold is calibrated before every session to prevent spurious activations.
153+
The agent learns for 50 episodes using $\alpha =$ 0.2, $\gamma =$ 0.99, following an $\epsilon$-greedy policy with $\epsilon=$ 0.1. Then, the agent operates in an evaluation mode for 50 episodes with $\alpha=\epsilon=0.0$. During this period, episodes are limited to 200 steps in case the agent executes a policy that never reaches the goal. A small delay is used between action execution and sensing to allow the arm to settle. The photocell threshold is calibrated before every session to prevent spurious activations.
136154

137155
\subsection{Features}
138156

0 commit comments

Comments
 (0)