Answers.Body: <blockquote>
  <p>Is the policy (based in the neural network) a stochastic policy? even if the action space is discrete?</p>
  </blockquote>
  <p>Yes. A discrete action space does not require a deterministic policy - it is possible to assign arbitrary probabilities to each action in each state provided each probability is in the range <span class="math-container">$[0,1]$</span> and the sum across all allowed actions is <span class="math-container">$1$</span>. The two concepts of determinism and discrete actions are entirely separate.</p>
  <p>The optimal policy in many situations can be deterministic. If there is only one deterministic optimal policy, your learned policy should be also close to deterministic if the learning process has been successful. That is, the probabilities of optimal actions should all be close to <span class="math-container">$1$</span>, all the rest close to <span class="math-container">$0$</span>.</p>
  <p>If there is more than one possible optimal policy, your learning agent may have learned a stochastic &quot;mix&quot; of them where in some states it is equally good to take more than one action and the probabilities may be split between those good actions. This will still be optimal and not a problem. If that is the case you should expect to see many action choices close to <span class="math-container">$0$</span> and in each state a select few (maybe one) that sum to close to <span class="math-container">$1$</span> between them.</p>
  <p>In the case of discrete actions, you can derive a deterministic policy from your neural network function by taking the argmax of the action probabilities. This is worth trying. It will round away bad actions that are close to 0 probability due to approximation in the neural network.</p>
  <p>In practice sometimes a little randomness in a policy works better for real-world problems with imprecise measurements or other unknowns. It may even be necessary for adversarial environments or where there is key information missing. The only way to find out though is to try both stochastic and deterministic interpretations of the neural network output for your policy.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-03T14:07:02.733Z
Answers.Text: Thank's for your answer. But, is deterministic or stochastic because "the policy return an action or return a probability" o because the policy is applied in a enviroment stochastic or deterministic?
Answers.UserDisplayName: Xtalker
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-03T14:12:36.257Z
Answers.Text: @Xtalker Sorry I do not understand your comment at all. Which components are you asking whether they are deterministic or stochastic? And in what cases?
Answers.UserDisplayName: Neil Slater
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-03T14:21:20.580Z
Answers.Text: The policy is the probability distribution over the actions. If for any action, $a$, $P(a) = 1$, then this is deterministic policy otherwise the probability distribution over action is stochastic policy. Note that, don't confuse stochastic environment with stochastic policy. They are not the same thing. You can have a stochastic policy in a deterministic environment.
Answers.UserDisplayName: Swakshar Deb
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-03T14:23:26.753Z
Answers.Text: Thinking the policy was trained in supervised mode, in a deterministic problem (such as a rubix cube). The action space is discrete and finite, and all actions has deterministics results. The output of the neural network will be a softmax function with a probability distribution about the confidence of the next action. However, the enviroment it is deterministic
Answers.UserDisplayName: Xtalker
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-03T15:47:48.693Z
Answers.Text: @Xtalker In that case the policy produced natually by the method you have used is stochastic (although it could approximate a deterministic one). You may find that changing the softmax to an argmax will give you a deterministic policy suitable for the problem, as described in the answer.
Answers.UserDisplayName: Neil Slater
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-03T13:25:07.660Z
Answers.LastActivityDate: 2021-04-09T21:33:52.517Z
Answers.LastEditDate: 2021-04-09T21:33:52.517Z
Answers.UserDisplayName: Neil Slater
Body: <p>If I trained a neural network with 4 outputs (one for each action: move down, up, left, and right) to move an agent through a grid (deterministic problem). The output of the neural network is a probability distribution over the 4 actions, due to the softmax activation function.</p>
  <p>Is the policy (based on the neural network) a stochastic policy, even if the action space is discrete?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-03T13:02:10.097Z
Comments.Text: Yes, for aforementioned case the policy is stochastic. You can select the action for example based on $\epsilon$-greedy policy. which is also a stochastic policy.
Comments.UserDisplayName: Swakshar Deb
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-03T13:06:30.053Z
Comments.Text: You said, "Is the policy (based in the neural network) a stochastic policy? even if the action space is discrete?" Why can't policy become stochastic in discrete action space? I can't understand your perspective.
Comments.UserDisplayName: Swakshar Deb
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-03T14:03:46.127Z
Comments.Text: I just want to give more details about the problem when i mentioned the discrete action space. Sorry, it's not important.
Comments.UserDisplayName: Xtalker
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-03T14:09:26.387Z
Comments.Text: In summary my question is: A policy Is deterministic because it return an action or return a probability"; or because the policy is applied in a stochastic enviroment or deterministic enviroment?
Comments.UserDisplayName: Xtalker
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-03T14:42:54.053Z
Comments.Text: Hi @Xtailker. The policy being deterministic means that the agent would always pick the same action in the same state. The policy being stochastic means that the action that is picked determined by the probabilities. So, if after computing softmax for the state, you use a random number to determine which action to use, then your policy is stochastic. If, for example, you decided to always use Argmax for deciding your action - then your policy would be deterministic. However, if you add probability epsilon to pick a random action instead of argmax, your policy would again become stochastic.
Comments.UserDisplayName: mark mark
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-03T14:45:02.223Z
Comments.Text: Policy is how the agent decides what to do. Stochastic policy means that there's some randomness involved in the decision making
Comments.UserDisplayName: mark mark
Tags: <neural-networks><policies><deterministic-policy><stochastic-policy><softmax-policy>
Title: Is a learned policy, for a deterministic problem, trained in a supervised process, a stochastic policy?
UserDisplayName: Xtalker
ThreadText: # Is a learned policy, for a deterministic problem, trained in a supervised process, a stochastic policy?
  
  (Asked by: username_0 on 2021-02-03)
  
  If I trained a neural network with 4 outputs (one for each action: move down, up, left, and right) to move an agent through a grid (deterministic problem). The output of the neural network is a probability distribution over the 4 actions, due to the softmax activation function.
  
  Is the policy (based on the neural network) a stochastic policy, even if the action space is discrete?
  
  **Tags:** neural-networks, policies, deterministic-policy, stochastic-policy, softmax-policy
  
  > **Comments:**
  > **username_1**: Yes, for aforementioned case the policy is stochastic. You can select the action for example based on $\epsilon$-greedy policy. which is also a stochastic policy.  
  > **username_1**: You said, "Is the policy (based in the neural network) a stochastic policy? even if the action space is discrete?" Why can't policy become stochastic in discrete action space? I can't understand your perspective.  
  > **username_0**: I just want to give more details about the problem when i mentioned the discrete action space. Sorry, it's not important.  
  > **username_0**: In summary my question is: A policy Is deterministic because it return an action or return a probability"; or because the policy is applied in a stochastic enviroment or deterministic enviroment?  
  > **username_2**: Hi @Xtailker. The policy being deterministic means that the agent would always pick the same action in the same state. The policy being stochastic means that the action that is picked determined by the probabilities. So, if after computing softmax for the state, you use a random number to determine which action to use, then your policy is stochastic. If, for example, you decided to always use Argmax for deciding your action - then your policy would be deterministic. However, if you add probability epsilon to pick a random action instead of argmax, your policy would again become stochastic.  
  > **username_2**: Policy is how the agent decides what to do. Stochastic policy means that there's some randomness involved in the decision making  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2021-02-03. Score: 1
  
  > Is the policy (based in the neural network) a stochastic policy? even if the action space is discrete?
  
  Yes. A discrete action space does not require a deterministic policy - it is possible to assign arbitrary probabilities to each action in each state provided each probability is in the range $[0,1]$ and the sum across all allowed actions is $1$. The two concepts of determinism and discrete actions are entirely separate.
  
  The optimal policy in many situations can be deterministic. If there is only one deterministic optimal policy, your learned policy should be also close to deterministic if the learning process has been successful. That is, the probabilities of optimal actions should all be close to $1$, all the rest close to $0$.
  
  If there is more than one possible optimal policy, your learning agent may have learned a stochastic "mix" of them where in some states it is equally good to take more than one action and the probabilities may be split between those good actions. This will still be optimal and not a problem. If that is the case you should expect to see many action choices close to $0$ and in each state a select few (maybe one) that sum to close to $1$ between them.
  
  In the case of discrete actions, you can derive a deterministic policy from your neural network function by taking the argmax of the action probabilities. This is worth trying. It will round away bad actions that are close to 0 probability due to approximation in the neural network.
  
  In practice sometimes a little randomness in a policy works better for real-world problems with imprecise measurements or other unknowns. It may even be necessary for adversarial environments or where there is key information missing. The only way to find out though is to try both stochastic and deterministic interpretations of the neural network output for your policy.
  
  > **Comments:**
  > **username_0**: Thank's for your answer. But, is deterministic or stochastic because "the policy return an action or return a probability" o because the policy is applied in a enviroment stochastic or deterministic?  
  > **username_3**: @username_0 Sorry I do not understand your comment at all. Which components are you asking whether they are deterministic or stochastic? And in what cases?  
  > **username_1**: The policy is the probability distribution over the actions. If for any action, $a$, $P(a) = 1$, then this is deterministic policy otherwise the probability distribution over action is stochastic policy. Note that, don't confuse stochastic environment with stochastic policy. They are not the same thing. You can have a stochastic policy in a deterministic environment.  
  > **username_0**: Thinking the policy was trained in supervised mode, in a deterministic problem (such as a rubix cube). The action space is discrete and finite, and all actions has deterministics results. The output of the neural network will be a softmax function with a probability distribution about the confidence of the next action. However, the enviroment it is deterministic  
  > **username_3**: @username_0 In that case the policy produced natually by the method you have used is stochastic (although it could approximate a deterministic one). You may find that changing the softmax to an argmax will give you a deterministic policy suitable for the problem, as described in the answer.  
  
  ---
  
  