Answers.Body: <p>I have not used learning rate schedules, but I do have experience with adjustable learning rates.</p>
  <p>The Keras callback <code>ReduceLROnPlateau</code> is useful for adjusting the learning rate. If you use it to monitor the validation loss versus training loss, you will avoid the danger of overfitting. Also, you can use the <code>ModelCheckpoint</code> callback to save the model with the lowest validation loss and use that to make predictions. The documentation is <a href="https://keras.io/api/callbacks/" rel="nofollow noreferrer">here</a>.</p>
  <p>I look at the validation loss as a deep valley in <span class="math-container">$N$</span> space, where <span class="math-container">$N$</span> is the number of trainable parameters. As you progress down the valley, it becomes increasingly narrower, so it is best to reduce the learning rate to get further down the valley (closer to the minimum). With the adjustable learning rate, you can start with a larger initial rate that converges faster, then reduces as needed to achieve a minimum loss.</p>
  <p>I wrote a custom callback that initially monitors the training loss and adjusts the learning rate based on that until the training accuracy achieves 95%, then it switches to adjusting the learning rate based on validation loss.</p>
  <p>I also am experimenting with a slightly different approach to training. On a given epoch, assume the quantity you are monitoring does NOT improve. That means that you have moved to a point in <span class="math-container">$N$</span> space (value of the weights) that is NOT as &quot;good&quot; as the point you were at in the previous epoch. So, instead of training from the point you are at in the current epoch, I set the weights back to what they were for the previous (better) epoch, reduce the learning rate then continue training from there. This appears to work rather well.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-07-18T15:14:06.413Z
Answers.Text: Yet, you answer holds for settings that are not reinforcement learning. In RL, we have the problem of "moving target" mitigated by using two neural networks.
Answers.UserDisplayName: HenDoNR
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-18T20:36:25.353Z
Answers.LastActivityDate: 2020-09-29T22:10:57.593Z
Answers.LastEditDate: 2020-09-29T22:10:57.593Z
Answers.UserDisplayName: Gerry P
Body: <p>How to best make use of learning rate scheduling in reinforcement learning?</p>
  
  <p>To me, a low learning rate towards the end to fine-tune what you've learned with subtle updates makes sense. But I don't see why over training time this should be linearly brought down. Wouldn't this increase overfitting too, as it promotes an early adopted policy to get further and further finetuned for the rest of the training? 
  Wouldn't it be better to keep it constant over the entire training so that when the agent finds novel experiences later, it still has a high enough learning rate to update its model?</p>
  
  <p>I also don't really know how these modern deep RL papers do it. The starcraft II paper by DeepMind, and the OpenAI hide and seek paper don't mention learning rate schedules for instance.</p>
  
  <p>Or are there certain RL environments where it's actually best to use something like a linear learning rate schedule?</p>
  
Tags: <reinforcement-learning><proximal-policy-optimization><learning-rate>
Title: How to best make use of learning rate scheduling in reinforcement learning?
UserDisplayName: SumakuTension
ThreadText: # How to best make use of learning rate scheduling in reinforcement learning?
  
  (Asked by: username_0 on 2020-05-18)
  
  How to best make use of learning rate scheduling in reinforcement learning?
  
  To me, a low learning rate towards the end to fine-tune what you've learned with subtle updates makes sense. But I don't see why over training time this should be linearly brought down. Wouldn't this increase overfitting too, as it promotes an early adopted policy to get further and further finetuned for the rest of the training?
  Wouldn't it be better to keep it constant over the entire training so that when the agent finds novel experiences later, it still has a high enough learning rate to update its model?
  
  I also don't really know how these modern deep RL papers do it. The starcraft II paper by DeepMind, and the OpenAI hide and seek paper don't mention learning rate schedules for instance.
  
  Or are there certain RL environments where it's actually best to use something like a linear learning rate schedule?
  
  **Tags:** reinforcement-learning, proximal-policy-optimization, learning-rate
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-05-18. Score: 1
  
  I have not used learning rate schedules, but I do have experience with adjustable learning rates.
  
  The Keras callback `ReduceLROnPlateau` is useful for adjusting the learning rate. If you use it to monitor the validation loss versus training loss, you will avoid the danger of overfitting. Also, you can use the `ModelCheckpoint` callback to save the model with the lowest validation loss and use that to make predictions. The documentation is [here](https://keras.io/api/callbacks/).
  
  I look at the validation loss as a deep valley in $N$ space, where $N$ is the number of trainable parameters. As you progress down the valley, it becomes increasingly narrower, so it is best to reduce the learning rate to get further down the valley (closer to the minimum). With the adjustable learning rate, you can start with a larger initial rate that converges faster, then reduces as needed to achieve a minimum loss.
  
  I wrote a custom callback that initially monitors the training loss and adjusts the learning rate based on that until the training accuracy achieves 95%, then it switches to adjusting the learning rate based on validation loss.
  
  I also am experimenting with a slightly different approach to training. On a given epoch, assume the quantity you are monitoring does NOT improve. That means that you have moved to a point in $N$ space (value of the weights) that is NOT as "good" as the point you were at in the previous epoch. So, instead of training from the point you are at in the current epoch, I set the weights back to what they were for the previous (better) epoch, reduce the learning rate then continue training from there. This appears to work rather well.
  
  > **Comments:**
  > **username_2**: Yet, you answer holds for settings that are not reinforcement learning. In RL, we have the problem of "moving target" mitigated by using two neural networks.  
  
  ---
  
  