Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfa37b5

Browse files
committed
fix bug
1 parent a6627b5 commit cfa37b5

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

Reinforcement_learning_TUT/5.2_Prioritized_Replay_DQN/RL_brain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def build_layers(s, c_names, n_l1, w_initializer, b_initializer):
234234
def store_transition(self, s, a, r, s_):
235235
if self.prioritized: # prioritized replay
236236
transition = np.hstack((s, [a, r], s_))
237-
self.memory.store(0.9, transition) # have 1 priority for newly arrived transition
237+
self.memory.store(1, transition) # have 1 priority for newly arrived transition
238238
else: # random replay
239239
if not hasattr(self, 'memory_counter'):
240240
self.memory_counter = 0

Reinforcement_learning_TUT/5.2_Prioritized_Replay_DQN/run_MountainCar.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ def train(RL):
6868
his_natural = train(RL_natural)
6969
his_prio = train(RL_prio)
7070

71-
plt.plot(his_natural[0, :], his_natural[1, :], c='b', label='natural DQN')
72-
plt.plot(his_prio[0, :], his_prio[1, :], c='r', label='DQN with prioritized replay')
71+
# compare based on first success
72+
plt.plot(his_natural[0, :], his_natural[1, :] - his_natural[1, 0], c='b', label='natural DQN')
73+
plt.plot(his_prio[0, :], his_prio[1, :] - his_prio[1, 0], c='r', label='DQN with prioritized replay')
7374
plt.legend(loc='best')
7475
plt.ylabel('total training time')
7576
plt.xlabel('episode')

0 commit comments

Comments
 (0)