# Tag Info

1

In the discussion about Neil Slater's answer (that he, sadly, deleted) it was pointed out that the policy $\pi$ should also depend on the horizon $h$. The decision of action $a$ can be influenced by how many steps are left. So, the "policy" in that case is actually a collection of policies $\pi_h(a|s)$ indexed by $h$ - the distance to horizon. ...

2

Let's do the code, so all the details are down. Encoding dictionary: codes, i = {}, 0 for nSquares in range(1,8): for direction in ["N", "NE", "E", "SE", "S", "SW", "W", "NW"]: codes[(nSquares,direction)] = i i += 1 You'll see that the codes dictionary will ...

1

Do I start off with the epsilon value at the end of the previous session, currently I reinitialize that as well? You should probably re-start with $\epsilon$ at the value you left off at. Using high values of epsilon may cause the neural network to forget some of what it learned from close-to-optimal policies in favour of learning possibly useless values of ...

0

Recall that the definition of a value function is $$v_\pi(s) = \mathbb{E}\left[G_t | S_t = s\right]\;.$$ That is, the expected future returns given from state $s$ at time $t$ when we follow our policy $\pi$ -- i.e. our trajectory is generated according to $\pi$. Using Monte Carlo methods we typically will estimate our value function by looking at the ...

3

We estimate a value using sampling on whole episodes, and we take this values to construct the target policy. The crucial bit that you are missing is that there is no single value of $V(s)$ (or $Q(s,a)$) of a state (or a state action pair). These value functions are always defined with respect to some policy $\pi(a|s)$ and is given the notation of $V^{\pi}(... 0 As you have mentioned using log is nicer because it makes multiplications to additions etc etc(it helps in numerical stability issues). But I think over here, the reason they are doing it like that is because of enforcing a simple constraint in a much more simpler way. In the __init__ we are noticing that the log_std is being formulated instead of the std ... 3 The AlphaZero paper mentions an "evaluation" step that seems to deal with the the problem similar to yours: ... we evaluate each new neural network checkpoint against the current best network$f_{\theta_*}before using it for data generation ... Each evaluation consists of 400 games ... If the new player wins by a margin of > 55% (to avoid ... 2 In short, the relevant class of a MDPs that guarantees the existence of a unique stationary state distribution for every deterministic stationary policy are unichain MDPs (Puterman 1994, Sect. 8.3). However, the unichain assumption does not mean that every policy will eventually visit every state. I believe your confusion arises from the difference between ... 0 Both your notation and terminology are quite confusing. For example, I'm not sure what is an "optimal" Bellman operator is. Here's a good clarification on definition of a Bellman operator. Likewise, your description of the DQN algorithm completely ignores the averaging over states/actions/rewards sampled from the replay memory. Trying to savage ... 2 Let's add a step index to your expression $$Q_{target}^{n} = (1-\tau)Q^{n-1}_{target} + \tau\, Q^{n-1}_{primary}$$ We can expand it one step further $$Q_{target}^{n} = (1-\tau)^2Q^{n-2}_{target} + (1-\tau)\tau\, Q^{n-2}_{primary} + \tau\, Q^{n-1}_{primary}$$ And further $$Q_{target}^{n} = (1-\tau)^3Q^{n-3}_{target} + (1-\tau)^2\tau\, Q^{n-3}_{primary} + (1-\... 0 In order to have anything resembling reinforcement learning you must at the very least have a set of states S and a set of actions A. In your formulation I can vaguely identify the set of states S as all possible (x,y,z) triplets. But don't see anything in your description that could be interpreted as a set of actions A. You either oversimplified ... 0 \mathcal S is just a set of all possible states. It doesn't matter if it's agents perceived state or true environment state, they are within the same set of states. Agent cannot perceive itself to be in some "middle" state that's not in \mathcal S, it might think that's in the state that's not the actual environment state but that state is also ... 0 If you already have some transition tuples then you can train a model to predict environment dynamics using these. However, you should be careful that your pre-gathered data is diverse enough to 'cover' enough of the state/action space so that your model remains accurate. For instance, when you start training your agent it will likely start to see more of ... 2 Assuming a continuous/uncountable state space, we can only estimate our value function using function approximation, so our estimates will never be true for all states simultaneously (because, loosely speaking, we have far more states than weights). If we can look at the (approximated) value of states we take in, say, 5 actions time, it is better to make a ... 1 They are not maximizing the gradient, the gradient is of the form $$\nabla_{\theta} J \approx \sum_{t=0}^T G_t \nabla_{\theta} \log(\pi_{\theta}(a_t|s_t))$$ that means that when implementing it in software you can form your objective as $$J = \sum_{t=0}^T G_t \log(\pi_{\theta}(a_t|s_t))$$ and then ... 1 My understanding from your question is that you have the following data generated from a random policy:$$[s_0, s_1, s_2 . . . s_n]$$That is, the state observed at each time step. You know nothing more about the MDP, such as the transition or reward functions. Although the MDP is discrete and fully observable (and thus usual RL theory is supported), you do ... 4 Yes, there are algorithms that try to predict the next state. Usually this will be a model based algorithm -- this is where the agent tries to make use of a model of the environment to help it learn. I'm not sure on the best resource to learn about this but my go-to recommendation is always the Sutton and Barto book. This paper introduces PlanGAN; the idea ... 2 Check out Imagination-Augmented Agents paper - seems like it does what you are talking about. The agent itself is the standard A3C that you are familiar with. The novelty is the "imagination" environment model which is trained to predict the behavior of the environment. 1 When the authors write go from$$\nabla_{\theta}J \propto \sum_s \mu(s) \sum_a q_{\pi}(s,a)\nabla_{\theta}\pi(a|s;\theta)\;$$to$$\nabla_{\theta}J = E_{\pi}\left[\sum_a q_{\pi}(S_t,a) \nabla_{\theta}\pi(a|S_t;\theta)\right]\;$$they are simply taking an expectation where the only random variable is the state S_t. This is because, as they say in the book, ... 0 I found the reason it wasn't learning. The issue was this line of code: q_target[torch.arange(states.size()[0]), actions] = rewards + (self.gamma * next_q_vals.max(dim=1)[0]) * (~dones).float() I had been using the tilde operator before to invert uint8 tensors, but recently I had updated to the latest version of pytorch that seems to have changed how the ... 1 RL is currently being applied to environments which are definitely not markovian, maybe they are weakly markovian with decreasing dependency. You need to provide details of your problem, if it is 1 step then any optimization system can be used. 1 Regarding your first question,$$V^{\pi}(s) = \sum_{a \in A}\pi(a|s)Q^{\pi}(s,a)$$so recovering the value function from Q really depends on what policy \pi you are using. Hence, you can't really recover the value function V(s) from the Q(s,a) values without knowing your policy distribution for state s. However, you can recover Q^{\pi}(s,a) values ... 1 If we use T as the notation for the terminal state, then the last action is a_{T-1}. This is because when you reach state s_T you don't take another action, which would be a_T, because the episode is finished upon reaching the terminal state. 2 generally the approach is to have a separate head. For example, imagine you have latent vector z_k, you would output two values: h(z_k) and f(z_k) where 0 \leq h \leq 1 and b_0 \leq f \leq b_1 where b_0 and b_1 are your bounds. In thios setup, during inference you would check h_k and if its greater than some threshold (usually .5), youd ... 1 The premise of this question is somewhat misleading. There is a deterministic optimal policy for a MDP, but this does not mean a stochastic optimal policy never exists. Talking about the optimal policy can be misleading, as there may be many different optimal policies. For example, certainly we could imagine an MDP where Q^*(s,a_0) = Q^*(s,a_1) for two ... 1 The fundamental idea behind policy gradient is just to maximise the return averaged across all probably trajectories, i.e$$\begin{align} J(\theta) &= E[\sum\limits_{t=1}^{\tau}r(s_t,a_t)]\\ &=E_{\tau\sim p(\tau)}[R(\tau)] \end{align}$Where$\tau\$ represents the probability of selecting a particular trajectory, if the trajectories all have fixed ...

1

In my experience, neural networks with convolutional layers take much much longer to train, so try increasing the number of iterations (time steps). After running, save the network model (I dont know how to do it in torch, but in tensorflow it was model.save("filename"+".h5") ). Then, load this saved model file and do a test run to see if ...

Top 50 recent answers are included