Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewards_history should be pb.rewards_history #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 8 additions & 6 deletions dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ def sample(self, frame_idx, batch_size=20, beta_frames=3000):
action_samples, reward_samples, next_state_samples, done_samples, indices, weights

def update_priorities(self, batch_indices, batch_priorities):
for idx, prio in zip(batch_indices, batch_priorities):
self.priorities[idx] = prio
# for idx, prio in zip(batch_indices, batch_priorities):
# self.priorities[idx] = prio
for idx in batch_indices:
self.priorities[idx] = batch_priorities

def __len__(self):
return self.cnt
Expand Down Expand Up @@ -316,8 +318,8 @@ def trainer(gamma=0.99,
state_next = process_state(state_next)
if done:
# there should be a huge punishment due to not crossing the flags
for i in range(len(rewards_history) - timestep_count, len(rewards_history)):
rewards_history[i] += reward / timestep_count
for i in range(len(pb.rewards_history) - timestep_count, len(pb.rewards_history)):
pb.rewards_history[i] += reward / timestep_count
else:
episode_reward += reward

Expand Down Expand Up @@ -413,8 +415,8 @@ def trainer(gamma=0.99,
# del done_history[:len(done_history)-max_memory]
if done: break
if not done:
for i in range(len(rewards_history) - timestep_count, len(rewards_history)):
rewards_history[i] -= 10000 / timestep_count
for i in range(len(pb.rewards_history) - timestep_count, len(pb.rewards_history)):
pb.rewards_history[i] -= 10000 / timestep_count

# reward of last n episodes
episode_reward_history.append(episode_reward)
Expand Down