Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions prioritized_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

class Memory: # stored as ( s, a, r, s_ ) in SumTree
def __init__(self, capacity, alpha=0.6, beta=0.4, beta_anneal_step=0.001, epsilon=0.00000001):
tree_capacity = 1
while tree_capacity < size:
tree_capacity *= 2
self.tree = SumTree(capacity)
self.capacity = capacity
self.a = alpha
Expand Down
1 change: 1 addition & 0 deletions sum_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class SumTree:
write = 0

def __init__(self, capacity):
assert capacity > 0 and capacity & (capacity - 1) == 0, "capacity must be positive and a power of 2."
self.capacity = capacity
self.tree = numpy.zeros(2 * capacity - 1)
self.data = numpy.zeros(capacity, dtype=object)
Expand Down