Answers.Body: <p>I would usually go with two separate networks for several reasons:</p>
  <ol>
  <li><p>Having a single network with two heads (one for policy and one for value) might be more challenging to train. I believe that training two separate networks is more stable. Especially in the case of PPO, you want to have small policy updates and you clip if the update would be too large. But now updating the value network also updates your policy, so you also have to clip the value loss as well, but what should be the clip size for the value net ? (see <a href="https://pi-tau.github.io/posts/actor-critic/#ppo" rel="nofollow noreferrer">here</a> for more)</p>
  </li>
  <li><p>In the case of a single network you have a single objective where you add the policy loss and the value loss: <span class="math-container">$L = L^{CLIP} + cL^{VF}$</span>, and now you need to adjust the hyperparameter <span class="math-container">$c$</span>. See Equation. 9 from the official <a href="https://arxiv.org/abs/1707.06347" rel="nofollow noreferrer">PPO paper</a>. Of course, if you have two networks you also have other hyper parameters, like different learning rates and so on, but these are not so much interdependent and can in general be adjusted separately, i.e. if your value net is training well but the policy is not, then don't touch the hyperparams of the value net and only adjust the hyperparams for the policy net.</p>
  </li>
  <li><p>The architecture of the two networks doesn't have to be the same. I usually use a much simpler network for the value network and a more complex model for the policy network. The task that the policy network is learning is much harder and at the end when all training is done you are actually using only this network. On the other hand your value network is trained on a regression task, i.e. predicting a single number, which is much easier and also better understood theoretically.</p>
  </li>
  <li><p>You might also want to regularize the models differently. For example I would regularize the value network using L2-regularization, but I would not use this for the policy network. For the policy network I would use entropy regularization.</p>
  </li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-26T22:06:55.340Z
Answers.LastActivityDate: 2023-08-26T22:06:55.340Z
Answers.UserDisplayName: pi-tau
Body: <p>I was reading <a href="https://stable-baselines3.readthedocs.io/en/master/guide/custom_policy.html" rel="nofollow noreferrer">this link</a> , and saw some creative architectures for PPO.</p>
  <p>I know the &quot;No Free Lunch Theorem&quot; and all, but what would be the logic/reasoning for why you would choose to have a different size/shape/depth for the actor vs. value func. networks in PPO?</p>
  <p>I just came across <a href="https://ai.stackexchange.com/questions/27932/how-does-sharing-parameters-between-the-policy-and-value-functions-help-in-ppo">this question</a>, which is related but not the same. It asks about the utility of sharing parameters across the two networks, to which the answer is essentially &quot;that might accelerate training by having less parameters&quot;. I think my question is distinct and more general.</p>
  
Tags: <deep-rl><proximal-policy-optimization><architecture>
Title: What would be the reason for having a different network architecture for the actor vs. value function networks in PPO?
UserDisplayName: Vladimir Belik
ThreadText: # What would be the reason for having a different network architecture for the actor vs. value function networks in PPO?
  
  (Asked by: username_0 on 2022-06-29)
  
  I was reading [this link](https://stable-baselines3.readthedocs.io/en/master/guide/custom_policy.html) , and saw some creative architectures for PPO.
  
  I know the "No Free Lunch Theorem" and all, but what would be the logic/reasoning for why you would choose to have a different size/shape/depth for the actor vs. value func. networks in PPO?
  
  I just came across [this question](https://ai.stackexchange.com/questions/27932/how-does-sharing-parameters-between-the-policy-and-value-functions-help-in-ppo), which is related but not the same. It asks about the utility of sharing parameters across the two networks, to which the answer is essentially "that might accelerate training by having less parameters". I think my question is distinct and more general.
  
  **Tags:** deep-rl, proximal-policy-optimization, architecture
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-08-26. Score: 0
  
  I would usually go with two separate networks for several reasons:
  
  1. Having a single network with two heads (one for policy and one for value) might be more challenging to train. I believe that training two separate networks is more stable. Especially in the case of PPO, you want to have small policy updates and you clip if the update would be too large. But now updating the value network also updates your policy, so you also have to clip the value loss as well, but what should be the clip size for the value net ? (see [here](https://pi-tau.github.io/posts/actor-critic/#ppo) for more)
  2. In the case of a single network you have a single objective where you add the policy loss and the value loss: $L = L^{CLIP} + cL^{VF}$, and now you need to adjust the hyperparameter $c$. See Equation. 9 from the official [PPO paper](https://arxiv.org/abs/1707.06347). Of course, if you have two networks you also have other hyper parameters, like different learning rates and so on, but these are not so much interdependent and can in general be adjusted separately, i.e. if your value net is training well but the policy is not, then don't touch the hyperparams of the value net and only adjust the hyperparams for the policy net.
  3. The architecture of the two networks doesn't have to be the same. I usually use a much simpler network for the value network and a more complex model for the policy network. The task that the policy network is learning is much harder and at the end when all training is done you are actually using only this network. On the other hand your value network is trained on a regression task, i.e. predicting a single number, which is much easier and also better understood theoretically.
  4. You might also want to regularize the models differently. For example I would regularize the value network using L2-regularization, but I would not use this for the policy network. For the policy network I would use entropy regularization.
  
  
  ---
  
  