Answers.Body: <p>For convergence to optimal value functions and optimal policies to be guaranteed in general, you need action coverage in a stochastic exploration policy. Typically that means implementing some kind of <span class="math-container">$\epsilon$</span>-soft policy but not necessarily <span class="math-container">$\epsilon$</span>-greedy. Without this, the agent will never look at the off-policy options that <em>might</em> be better. The agent also needs data about bad actions that it should not take, otherwise it will not learn to avoid them by itself.</p>
  <p>In general, swapping the <span class="math-container">$\epsilon$</span>-greedy policy out for a deterministic expert policy will not work. However, there are a few ways that it could be made to work:</p>
  <ul>
  <li><p>The expert policy is stochastic and has coverage, but prefers &quot;better&quot; actions. You still need full coverage for the Q-learning agent to estimate returns from bad actions, unless the expert policy is also going to be applied in production to avoid those bad actions.</p>
  </li>
  <li><p>Instead of <em>starting</em> with an <span class="math-container">$\epsilon$</span>-greedy policy and a high value e.g. <span class="math-container">$\epsilon = 1$</span>, start with the expert policy for some fixed number of iterations, enough for the agent to approximately learn the value function for the expert policy. Then switch back to <span class="math-container">$\epsilon$</span>-greedy with a relatively low value for exploration e.g. <span class="math-container">$\epsilon = 0.1$</span>. This will initialise your agent with knowledge from the expert and help speed up leaning if that expert policy is any good.</p>
  </li>
  <li><p>If you have good knowledge of when the expert policy is truly optimal, and can detect that from the state, then use it instead of Q values in those states. You may still want an <span class="math-container">$\epsilon$</span> probability of taking random action instead applied to that choice, depending on whether you want the agent to properly learn about the worse alternatives. I have successfully used this approach for an agent learning a board game, where minimax searches that find forced end game results can easily be tracked and used in preference to Q tables when they apply.</p>
  </li>
  <li><p>If the environment is highly stochastic - e.g. in a board game using dice - it may not matter that you are using a deterministic fallback policy instead of <span class="math-container">$\epsilon$</span>-greedy, because the agent will see enough variation in states despite not actively exploring itself.</p>
  </li>
  <li><p>If the expert policy is not necessarily optimal, but is perfect at avoiding terrible decisions, use it to filter available actions. This would need to be done in production as well as during learning, because the agent will never learn about those terrible decisions unless it experiences them. Although you could also fake that experience and feed it to the update step if the expert is also very good as emulating what would happen - this might be possible if the expert can reliably detect that the episode would end with a certain reward immediately for example.</p>
  </li>
  <li><p>Any hybrid variation of the above ideas, such as switching between three policies: greedy Q-table, expert and random choice based on evolving probabilities and knowledge of when the expert policy is best applied.</p>
  </li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-24T13:42:10.523Z
Answers.LastActivityDate: 2022-03-24T13:53:39.447Z
Answers.LastEditDate: 2022-03-24T13:53:39.447Z
Answers.UserDisplayName: Neil Slater
Body: <p>In deep Q-learning we typically use epsilon-greedy policy during training. We choose a random action for a certain probability <span class="math-container">$\epsilon$</span>, and choose the action that maximize the current Q-value estimate for probability <span class="math-container">$1-\epsilon$</span>, and the value of <span class="math-container">$\epsilon$</span> decays slowly over the training process</p>
  <p>I am wondering if directly swapping the random action with an expert policy can speed-up the Q-learning process?</p>
  
Tags: <reinforcement-learning><deep-rl><q-learning><dqn>
Title: Can directly using expert policy in epsilon-greedy speed-up Q-learning?
UserDisplayName: Cloudy
ThreadText: # Can directly using expert policy in epsilon-greedy speed-up Q-learning?
  
  (Asked by: username_0 on 2022-03-24)
  
  In deep Q-learning we typically use epsilon-greedy policy during training. We choose a random action for a certain probability $\epsilon$, and choose the action that maximize the current Q-value estimate for probability $1-\epsilon$, and the value of $\epsilon$ decays slowly over the training process
  
  I am wondering if directly swapping the random action with an expert policy can speed-up the Q-learning process?
  
  **Tags:** reinforcement-learning, deep-rl, q-learning, dqn
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-03-24. Score: 1
  
  For convergence to optimal value functions and optimal policies to be guaranteed in general, you need action coverage in a stochastic exploration policy. Typically that means implementing some kind of $\epsilon$-soft policy but not necessarily $\epsilon$-greedy. Without this, the agent will never look at the off-policy options that *might* be better. The agent also needs data about bad actions that it should not take, otherwise it will not learn to avoid them by itself.
  
  In general, swapping the $\epsilon$-greedy policy out for a deterministic expert policy will not work. However, there are a few ways that it could be made to work:
  
  * The expert policy is stochastic and has coverage, but prefers "better" actions. You still need full coverage for the Q-learning agent to estimate returns from bad actions, unless the expert policy is also going to be applied in production to avoid those bad actions.
  * Instead of *starting* with an $\epsilon$-greedy policy and a high value e.g. $\epsilon = 1$, start with the expert policy for some fixed number of iterations, enough for the agent to approximately learn the value function for the expert policy. Then switch back to $\epsilon$-greedy with a relatively low value for exploration e.g. $\epsilon = 0.1$. This will initialise your agent with knowledge from the expert and help speed up leaning if that expert policy is any good.
  * If you have good knowledge of when the expert policy is truly optimal, and can detect that from the state, then use it instead of Q values in those states. You may still want an $\epsilon$ probability of taking random action instead applied to that choice, depending on whether you want the agent to properly learn about the worse alternatives. I have successfully used this approach for an agent learning a board game, where minimax searches that find forced end game results can easily be tracked and used in preference to Q tables when they apply.
  * If the environment is highly stochastic - e.g. in a board game using dice - it may not matter that you are using a deterministic fallback policy instead of $\epsilon$-greedy, because the agent will see enough variation in states despite not actively exploring itself.
  * If the expert policy is not necessarily optimal, but is perfect at avoiding terrible decisions, use it to filter available actions. This would need to be done in production as well as during learning, because the agent will never learn about those terrible decisions unless it experiences them. Although you could also fake that experience and feed it to the update step if the expert is also very good as emulating what would happen - this might be possible if the expert can reliably detect that the episode would end with a certain reward immediately for example.
  * Any hybrid variation of the above ideas, such as switching between three policies: greedy Q-table, expert and random choice based on evolving probabilities and knowledge of when the expert policy is best applied.
  
  
  ---
  
  