Skip to content

Instantly share code, notes, and snippets.

@pythonlessons
Last active January 15, 2020 06:44
Show Gist options
  • Select an option

  • Save pythonlessons/660d4e675cf5745afbb1e6343f93349c to your computer and use it in GitHub Desktop.

Select an option

Save pythonlessons/660d4e675cf5745afbb1e6343f93349c to your computer and use it in GitHub Desktop.
05_CartPole-reinforcement-learning_PER_D3QN
def update(self, tree_index, priority):
# Change = new priority score - former priority score
change = priority - self.tree[tree_index]
self.tree[tree_index] = priority
# then propagate the change through tree
# this method is faster than the recursive loop
while tree_index != 0:
tree_index = (tree_index - 1) // 2
self.tree[tree_index] += change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment