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

Update the code for the MLP RL baseline to be more aligned with latest #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion src/behavior/mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ def get_action_and_value(self, nobs: torch.Tensor, action=None):
)

def load_bc_weights(self, bc_weights_path):
wts = torch.load(bc_weights_path)["model_state_dict"]

wts = torch.load(bc_weights_path)

if "model_state_dict" in wts:
wts = wts["model_state_dict"]

# Filter out keys not starting with "model"
model_wts = {k: v for k, v in wts.items() if k.startswith("model")}
Expand Down
3 changes: 2 additions & 1 deletion src/config/base_mlp_ppo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ critic:
last_layer_std: 0.25
last_layer_activation: null

init_logstd: -5.0
init_logstd: -5.0
learn_std: true

total_timesteps: 500_000_000
num_envs: 1024
Expand Down
1 change: 1 addition & 0 deletions src/train/ppo.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ def main(cfg: DictConfig):
ref_dist = Normal(action_mean, action_std)
kl_loss = -ref_dist.log_prob(mb_new_actions).mean()
policy_loss = policy_loss + cfg.kl_coef * kl_loss

# Total loss
loss = policy_loss + cfg.vf_coef * v_loss

Expand Down