Measurement & mixed states for quantum systems.
Notes on measurement for quantum systems.
This post documents my implementation of the Dueling Double Deep Q Network with Priority Experience Replay (Duel DDQN with PER) algorithm.
A Dueling Double Deep Q Network with Priority Experience Replay (Duel DDQN with PER) implementation in tensorflow. The code is tested with Gym’s discrete action space environment, CartPole-v0 on Colab.
Code on my Github
If Github is not loading the Jupyter notebook, a known Github issue, click here to view the notebook on Jupyter’s nbviewer.
Model network = \(Q_{\theta}\)
Model parameter = \(\theta\)
Model network Q value = \(Q_{\theta}\) (s, a)
Target network = \(Q_{\phi}\)
Target parameter = \(\phi\)
Target network Q value = \(Q_{\phi}\) (\(s^{'}\), \(a^{'}\))
A small constant to ensure that no sample has 0 probability to be selected = e
Hyper parameter = \(\alpha\)
Hyper parameter = \(\beta\)
Minibatch size = k
Replay memory size = N
TD target = r (s, a) \(+\) \(\gamma\) \(Q_{\phi}\) (\(s^{'}\), \(argmax_{a^{'}}\) \(Q_{\theta}\) (s\(^{'}\), a\(^{'}\)))
TD error = \({\delta}\) = (TD target) \(-\) (Model network Q value) = [r (s, a) \(+\) \(\gamma\) \(Q_{\phi}\) (\(s^{'}\), \(argmax_{a^{'}}\) \(Q_{\theta}\) (s\(^{'}\), a\(^{'}\)))] \(-\) \(Q_{\theta}\) (s, a)
\(priority_{i}\) = \(p_{i}\) = \({|\delta_{i}|}\) \(+\) e
probability(i) = P(i) = \(\frac{p_{i}^{\alpha}} {\sum_{k}p_{k}^{\alpha}}\)
weights = \(w_{i}\) = (N \(\cdot\) P(i)) \(^{-\beta}\)
Sum tree:
Assume an example of a sum tree with 7 nodes (with 4 leaves which corresponds to the replay memory size):
At initialization:
When item 1 is added:
When item 2 is added:
When item 3 is added:
When item 4 is added:
When item 5 is added:
Figure below shows the corresponding code & array contents. The tree represents the entire sum tree while data represents the leaves.
In the implementation, only one sumTree object is needed to store the collected experiences, this sumTree object resides in the Replay_memory class. The sumTree object has number of leaves = replay memory size = capacity. The data array in sumTree object stores an Exp object, which is a sample of experience.
The following code decides how to sample:
def sample(self, k): # k = minibatch size
batch = []
# total_p() gives the total sum of priorities of the leaves in the sumTree
# which is the value stored in the root node
segment = self.tree.total_p() / k
for i in range(k):
a = segment * i # start of segment
b = segment * (i + 1) # end of segment
s = np.random.uniform(a, b) # rand value between a, b
(idx, p, data) = self.tree.get(s)
batch.append( (idx, p, data) )
return batch
Refer to appendix B.2.1, under the section, “Proportional prioritization”, from the original (Schaul et al., 2016) paper for sampling details.
Prioritized experience replay (Schaul et al., 2016)
Notes on measurement for quantum systems.
Notes on quantum states as a generalization of classical probabilities.
The location of ray_results folder in colab when using RLlib &/or tune.
My attempt to implement a water down version of PBT (Population based training) for MARL (Multi-agent reinforcement learning).
Ray (0.8.2) RLlib trainer common config from:
How to calculate dimension of output from a convolution layer?
Changing Google drive directory in Colab.
Notes on the probability for linear regression (Bayesian)
Notes on the math for RNN back propagation through time(BPTT), part 2. The 1st derivative of \(h_t\) with respect to \(h_{t-1}\).
Notes on the math for RNN back propagation through time(BPTT).
Filter rows with same column values in a Pandas dataframe.
Building & testing custom Sagemaker RL container.
Demo setup for simple (reinforcement learning) custom environment in Sagemaker. This example uses Proximal Policy Optimization with Ray (RLlib).
Basic workflow of testing a Django & Postgres web app with Travis (continuous integration) & deployment to Heroku (continuous deployment).
Basic workflow of testing a dockerized Django & Postgres web app with Travis (continuous integration) & deployment to Heroku (continuous deployment).
Introducing a delay to allow proper connection between dockerized Postgres & Django web app in Travis CI.
Creating & seeding a random policy class in RLlib.
A custom MARL (multi-agent reinforcement learning) environment where multiple agents trade against one another in a CDA (continuous double auction).
This post demonstrate how setup & access Tensorflow graphs.
This post demonstrates how to create customized functions to bundle commands in a .bash_profile file on Mac.
This post documents my implementation of the Random Network Distillation (RND) with Proximal Policy Optimization (PPO) algorithm. (continuous version)
This post documents my implementation of the Distributed Proximal Policy Optimization (Distributed PPO or DPPO) algorithm. (Distributed continuous version)
This post documents my implementation of the A3C (Asynchronous Advantage Actor Critic) algorithm (Distributed discrete version).
This post documents my implementation of the A3C (Asynchronous Advantage Actor Critic) algorithm. (multi-threaded continuous version)
This post documents my implementation of the A3C (Asynchronous Advantage Actor Critic) algorithm (discrete). (multi-threaded discrete version)
This post demonstrates how to accumulate gradients with Tensorflow.
This post demonstrates a simple usage example of distributed Tensorflow with Python multiprocessing package.
This post documents my implementation of the N-step Q-values estimation algorithm.
This post demonstrates how to use the Python’s multiprocessing package to achieve parallel data generation.
This post provides a simple usage examples for common Numpy array manipulation.
This post documents my implementation of the Dueling Double Deep Q Network with Priority Experience Replay (Duel DDQN with PER) algorithm.
This post documents my implementation of the Dueling Double Deep Q Network (Dueling DDQN) algorithm.
This post documents my implementation of the Double Deep Q Network (DDQN) algorithm.
This post documents my implementation of the Deep Q Network (DQN) algorithm.