Answers.Body: <p>It does not matter, target should converge to the main network after long enough training. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-16T21:06:23.873Z
Answers.LastActivityDate: 2018-07-16T21:06:23.873Z
Answers.UserDisplayName: Afshin Oroojlooy
Answers.Body: <blockquote>
    <p>So my question now is, after the training is complete, which of the two networks mu or mu' should be used for making predictions?</p>
  </blockquote>
  
  <p>After training is "complete", use mu, i.e., the online network because this is the most updated actor network you have.  In the most ideal case, mu' will be equal to mu.  But if your training is truly complete, mu = mu'.</p>
  
  <blockquote>
    <p>Equivalently to the training phase I suppose that mu should be used without the exploration noise but since it is mu' that is used during the training for predicting the "true" (unnoisy) action for the reward computation, I'm apt to use mu'.</p>
  </blockquote>
  
  <p>In the training phase, you must use exploration noise when mu maps states to actions.  The actor is a policy gradient, i.e. based on policy iteration.  So it will directly map to an action everytime.  If no exploratory noise is added, it will map to the same value every time, unless you update your network weights.  What this means is that if you're given some states, s.  Without exploration noise, the actor will always output the same actions, and never explore.</p>
  
  <p>mu' is ONLY used for the supervised learning portion of DDPG, where it stabilizes training of 2 neural networks that essentially train off each other.  </p>
  
  <p>Imagine this problem: a worker and his supervisor in a factory.  Both the worker and the supervisor knows nothing at the start (initialized neural networks).  The worker's first action is to pick up a 200 lb box.  The supervisor then positively rewards him. So from this, the worker learned that picking up heavy objects = good. The worker then picks up another heavy box, and this time the supervisor yells at him because the supervisor learned that its dangerous.  So now the worker himself is confused, because he does not know if picking up heavy objects is good or bad because the supervisor himself changes his mind.  </p>
  
  <p>In DDPG, the actor and critic behaves the same way.  So we introduce target networks to make it so both the actor and critic don't keep changing their minds, so they can actually learn things.</p>
  
  <blockquote>
    <p>Or does this even matter? If the training was to last long enough shouldn't both versions of the actor have converged to the same state?</p>
  </blockquote>
  
  <p>That is correct, but in reality, that is very rare.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-10T21:56:59.677Z
Answers.LastActivityDate: 2018-09-10T21:56:59.677Z
Answers.UserDisplayName: Rui Nian
Body: <h1>The situation</h1>
  
  <p>I am referring to the paper <a href="https://arxiv.org/abs/1509.02971" rel="noreferrer">T. P. Lillicrap et al, "Continuous control with deep reinforcement learning"</a> where they discuss deep learning in the context of continuous action spaces ("Deep Deterministic Policy Gradient").</p>
  
  <p>Based on the DPG approach ("Deterministic Policy Gradient", see <a href="http://proceedings.mlr.press/v32/silver14.pdf" rel="noreferrer">D. Silver et al, "Deterministic Policy Gradient Algorithms"</a>), which employs two neural networks to approximate the actor function <code>mu(s)</code> and the critic function <code>Q(s,a)</code>, they use a similar structure.<br>
  However one characteristic they found is that in order to make the learning converge it is necessary to have two additional "target" networks <code>mu'(s)</code> and <code>Q'(s,a)</code> which are used to calculate the target ("true") value of the reward:</p>
  
  <pre><code>y_t = r(s_t, a) + gamma * Q'(s_t1, mu'(s_t1))
  </code></pre>
  
  <p>Then after each training step a "soft" update of the target weights <code>w_mu', w_Q'</code> with the actual weights <code>w_mu, w_Q</code> is performed:</p>
  
  <pre><code>w' = (1 - tau)*w' + tau*w
  </code></pre>
  
  <p>where <code>tau &lt;&lt; 1</code>. According to the paper</p>
  
  <blockquote>
    <p>This means that the target values are constrained to change slowly, greatly improving the stability of learning.</p>
  </blockquote>
  
  <p>So the target networks <code>mu'</code> and <code>Q'</code> are used to predict the "true" (target) value of the expected reward which the other two networks try to approximate during the learning phase.</p>
  
  <p>They sketch the training procedure as follows:</p>
  
  <p><a href="https://i.sstatic.net/BBNRP.png" rel="noreferrer"><img src="https://i.sstatic.net/BBNRP.png" alt="DDPG Sketch"></a></p>
  
  <h1>The question</h1>
  
  <p>So my question now is, after the training is complete, which of the two networks <code>mu</code> or <code>mu'</code> should be used for making predictions?</p>
  
  <p>Equivalently to the training phase I suppose that <code>mu</code> should be used without the exploration noise but since it is <code>mu'</code> that is used during the training for predicting the "true" (unnoisy) action for the reward computation, I'm apt to use <code>mu'</code>.</p>
  
  <p>Or does this even matter? If the training was to last long enough shouldn't both versions of the actor have converged to the same state?</p>
  
Tags: <deep-learning><reinforcement-learning><deep-neural-networks><q-learning>
Title: Should the actor or actor-target model be used to make predictions after training is complete (DDPG)?
UserDisplayName: a_guest
ThreadText: # Should the actor or actor-target model be used to make predictions after training is complete (DDPG)?
  
  (Asked by: username_0 on 2018-02-27)
  
  The situation
  I am referring to the paper T. P. Lillicrap et al, "Continuous control with deep reinforcement learning" where they discuss deep learning in the context of continuous action spaces ("Deep Deterministic Policy Gradient").
  Based on the DPG approach ("Deterministic Policy Gradient", see D. Silver et al, "Deterministic Policy Gradient Algorithms"), which employs two neural networks to approximate the actor function mu(s) and the critic function Q(s,a), they use a similar structure.
  However one characteristic they found is that in order to make the learning converge it is necessary to have two additional "target" networks mu'(s) and Q'(s,a) which are used to calculate the target ("true") value of the reward:
  y_t = r(s_t, a) + gamma * Q'(s_t1, mu'(s_t1))
  
  Then after each training step a "soft" update of the target weights w_mu', w_Q' with the actual weights w_mu, w_Q is performed:
  w' = (1 - tau)*w' + tau*w
  
  where tau << 1. According to the paper
  
  This means that the target values are constrained to change slowly, greatly improving the stability of learning.
  
  So the target networks mu' and Q' are used to predict the "true" (target) value of the expected reward which the other two networks try to approximate during the learning phase.
  They sketch the training procedure as follows:
  
  The question
  So my question now is, after the training is complete, which of the two networks mu or mu' should be used for making predictions?
  Equivalently to the training phase I suppose that mu should be used without the exploration noise but since it is mu' that is used during the training for predicting the "true" (unnoisy) action for the reward computation, I'm apt to use mu'.
  Or does this even matter? If the training was to last long enough shouldn't both versions of the actor have converged to the same state?
  
  **Tags:** deep-learning, reinforcement-learning, deep-neural-networks, q-learning
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-07-16. Score: 1
  
  It does not matter, target should converge to the main network after long enough training.
  
  
  ---
  
  ### Answer by username_2 on 2018-09-10. Score: 1
  
  > So my question now is, after the training is complete, which of the two networks mu or mu' should be used for making predictions?
  
  After training is "complete", use mu, i.e., the online network because this is the most updated actor network you have. In the most ideal case, mu' will be equal to mu. But if your training is truly complete, mu = mu'.
  
  > Equivalently to the training phase I suppose that mu should be used without the exploration noise but since it is mu' that is used during the training for predicting the "true" (unnoisy) action for the reward computation, I'm apt to use mu'.
  
  In the training phase, you must use exploration noise when mu maps states to actions. The actor is a policy gradient, i.e. based on policy iteration. So it will directly map to an action everytime. If no exploratory noise is added, it will map to the same value every time, unless you update your network weights. What this means is that if you're given some states, s. Without exploration noise, the actor will always output the same actions, and never explore.
  
  mu' is ONLY used for the supervised learning portion of DDPG, where it stabilizes training of 2 neural networks that essentially train off each other.
  
  Imagine this problem: a worker and his supervisor in a factory. Both the worker and the supervisor knows nothing at the start (initialized neural networks). The worker's first action is to pick up a 200 lb box. The supervisor then positively rewards him. So from this, the worker learned that picking up heavy objects = good. The worker then picks up another heavy box, and this time the supervisor yells at him because the supervisor learned that its dangerous. So now the worker himself is confused, because he does not know if picking up heavy objects is good or bad because the supervisor himself changes his mind.
  
  In DDPG, the actor and critic behaves the same way. So we introduce target networks to make it so both the actor and critic don't keep changing their minds, so they can actually learn things.
  
  > Or does this even matter? If the training was to last long enough shouldn't both versions of the actor have converged to the same state?
  
  That is correct, but in reality, that is very rare.
  
  
  ---
  
  