Skip to content

Commit

Permalink
fixing the overcounting of cummulative cost
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaustubh Mani committed Sep 25, 2023
1 parent ef1bb58 commit e435e10
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cleanrl/dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,13 @@ def get_random_action():
if "episode" not in info:
continue

ep_cost = torch.sum(f_costs[last_step:global_step]).item()
cum_cost += torch.sum(f_costs).item()
if args.fine_tune_risk:
ep_cost = torch.sum(f_costs)
cum_cost += ep_cost
else:
ep_cost = torch.sum(f_costs[last_step:global_step]).item()
cum_cost = torch.sum(f_costs).item()

last_step = global_step
print(f"global_step={global_step}, episodic_return={info['episode']['r']}")
writer.add_scalar("charts/episodic_return", info["episode"]["r"], global_step)
Expand Down

0 comments on commit e435e10

Please sign in to comment.