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

Add save_freq option to CAPQL train method #122

Merged
merged 1 commit into from
Oct 19, 2024
Merged
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: 4 additions & 2 deletions morl_baselines/multi_policy/capql/capql.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ def train(
eval_freq: int = 10000,
reset_num_timesteps: bool = False,
checkpoints: bool = False,
save_freq: int = 10000,
):
"""Train the agent.

Expand All @@ -403,6 +404,7 @@ def train(
eval_freq (int): Number of timesteps between evaluations during an iteration.
reset_num_timesteps (bool): Whether to reset the number of timesteps.
checkpoints (bool): Whether to save checkpoints.
save_freq (int): Number of timesteps between checkpoints.
"""
if self.log:
self.register_additional_config(
Expand Down Expand Up @@ -476,7 +478,7 @@ def train(
)

# Checkpoint
if checkpoints:
self.save(filename="CAPQL", save_replay_buffer=False)
if checkpoints and self.global_step % save_freq == 0:
self.save(filename=f"CAPQL step={self.global_step}", save_replay_buffer=False)

self.close_wandb()
Loading