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

fix tqdm issue #481

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions tianshou/trainer/offpolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def offpolicy_trainer(
env_step += int(result["n/st"])
t.update(result["n/st"])
logger.log_train_data(result, env_step)
last_rew = result['rew'] if 'rew' in result else last_rew
last_len = result['len'] if 'len' in result else last_len
last_rew = result['rew'] if result["n/ep"] > 0 else last_rew
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result["n/ep"] corresponds to episode_count in collector.py. If episode_count > 0, then the 'rew' and 'len' must exist.

last_len = result['len'] if result["n/ep"] > 0 else last_len
data = {
"env_step": str(env_step),
"rew": f"{last_rew:.2f}",
Expand Down
4 changes: 2 additions & 2 deletions tianshou/trainer/onpolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def onpolicy_trainer(
env_step += int(result["n/st"])
t.update(result["n/st"])
logger.log_train_data(result, env_step)
last_rew = result['rew'] if 'rew' in result else last_rew
last_len = result['len'] if 'len' in result else last_len
last_rew = result['rew'] if result["n/ep"] > 0 else last_rew
last_len = result['len'] if result["n/ep"] > 0 else last_len
data = {
"env_step": str(env_step),
"rew": f"{last_rew:.2f}",
Expand Down