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

disable empirical normalizer updates on resume training #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions rsl_rl/runners/on_policy_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ def __init__(self, env: VecEnv, train_cfg, log_dir=None, device="cpu"):
self.save_interval = self.cfg["save_interval"]
self.empirical_normalization = self.cfg["empirical_normalization"]
if self.empirical_normalization:
self.obs_normalizer = EmpiricalNormalization(shape=[num_obs], until=1.0e8).to(self.device)
self.critic_obs_normalizer = EmpiricalNormalization(shape=[num_critic_obs], until=1.0e8).to(self.device)
if train_cfg.get("resume") == True:
until = 0
else:
until = 1.0e8
self.obs_normalizer = EmpiricalNormalization(shape=[num_obs], until=until).to(self.device)
self.critic_obs_normalizer = EmpiricalNormalization(shape=[num_critic_obs], until=until).to(self.device)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the correct way to solve the problem is to save and load the internal count of EmpiricalNormalization. The current solution breaks if you resume training before 1.0e8 steps

Copy link
Author

Choose a reason for hiding this comment

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

https://github.com/tasdep/rsl_rl-1/blob/f2b721aae7c33a34155a0db6135a559b75513334/rsl_rl/runners/on_policy_runner.py#L257-L262
what is saved_dict[infos] intended for? Or should I just add another term to the saved_dict?

else:
self.obs_normalizer = torch.nn.Identity() # no normalization
self.critic_obs_normalizer = torch.nn.Identity() # no normalization
Expand Down