Skip to content

Commit

Permalink
added avg return and score
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaustubh Mani committed Sep 29, 2023
1 parent d6519be commit 563cf4b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cleanrl/sac_continuous_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def get_action(self, x):
start_time = time.time()

cum_cost, ep_cost = 0, 0

scores = []
# TRY NOT TO MODIFY: start the game
obs, _ = envs.reset()
for global_step in range(cfg.total_timesteps):
Expand Down Expand Up @@ -311,7 +311,11 @@ def get_action(self, x):
# print(info)
if info is None:
continue

scores.append(info['episode']['r'])

#avg_total_reward = np.mean(test_policy(cfg, agent, envs, device=device, risk_model=risk_model))
avg_mean_score = np.mean(scores[-100:])
writer.add_scalar("Results/Avg_Return", avg_mean_score, global_step)
print(f"global_step={global_step}, episodic_return={info['episode']['r']}")
writer.add_scalar("charts/episodic_return", info["episode"]["r"], global_step)
writer.add_scalar("charts/episodic_length", info["episode"]["l"], global_step)
Expand Down

0 comments on commit 563cf4b

Please sign in to comment.