Skip to content

Commit 8781232

Browse files
committed
auto memlen for PER as 1/3 epi * timestep
1 parent efa048e commit 8781232

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rl/memory/prioritized_exp_replay.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ class PrioritizedExperienceReplay(LinearMemoryWithForgetting):
1212
memory unit
1313
'''
1414

15-
def __init__(self, env_spec, max_mem_len=10000, e=0.01, alpha=0.6,
15+
def __init__(self, env_spec, max_mem_len=None, e=0.01, alpha=0.6,
1616
**kwargs):
17+
if max_mem_len is None: # auto calculate mem len
18+
max_timestep = env_spec['timestep_limit']
19+
max_epis = env_spec['problem']['MAX_EPISODES']
20+
memory_epi = np.ceil(max_epis / 3.).astype(int)
21+
max_mem_len = max(10**6, max_timestep * memory_epi)
1722
super(PrioritizedExperienceReplay, self).__init__(
1823
env_spec, max_mem_len)
1924
self.exp_keys.append('error')

0 commit comments

Comments
 (0)