thu-ml/tianshou

How to monitor the episode/epoch return/length in Tianshou?

PingH129 opened this issue · 1 comments

  • I have marked all applicable categories:
    • exception-raising bug
    • RL algorithm bug
    • documentation request (i.e. "X is missing from the documentation.")
    • new feature request
    • design request (i.e. "X should be changed to Y.")
  • [+] I have visited the source website
  • [+] I have searched through the issue tracker for duplicates
  • [+] I have mentioned version numbers, operating system and environment, where applicable:
    import tianshou, gymnasium as gym, torch, numpy, sys
    print(tianshou.__version__, gym.__version__, torch.__version__, numpy.__version__, sys.version, sys.platform)

I'm using the trainer in Tianshou for MARL, but how can I monitor the episode/epoch return and length in tianshou in the training process?

You should check the collector's return value. It has episodic statistic number. For example:

return CollectStats.with_autogenerated_stats(
returns=np.array(episode_returns),
lens=np.array(episode_lens),
n_collected_episodes=num_collected_episodes,
n_collected_steps=step_count,
collect_time=collect_time,
collect_speed=step_count / collect_time,
)