From 9bb63078ae1fc640f00846e8272329a558c34363 Mon Sep 17 00:00:00 2001 From: Mosayeb Shams Date: Mon, 12 Jun 2023 15:31:13 +0100 Subject: [PATCH] Make the policy training deterministic --- closed_loop_AFC/jet_cylinder/ppo_controller.py | 4 +++- closed_loop_AFC/rotating_cylinder/ppo_controller.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/closed_loop_AFC/jet_cylinder/ppo_controller.py b/closed_loop_AFC/jet_cylinder/ppo_controller.py index 62dc737..b09e12f 100644 --- a/closed_loop_AFC/jet_cylinder/ppo_controller.py +++ b/closed_loop_AFC/jet_cylinder/ppo_controller.py @@ -385,9 +385,11 @@ def parse_args(): logger.error("wandb is not installed, run `pip install gymprecice[vis]`") raise err - # TRY NOT TO MODIFY: seeding + # deterministic training random.seed(args.seed) np.random.seed(args.seed) + torch.manual_seed(args.seed) + torch.backends.cudnn.deterministic = args.torch_deterministic def make_env(options, idx, wrappers=None): def _make_env(): diff --git a/closed_loop_AFC/rotating_cylinder/ppo_controller.py b/closed_loop_AFC/rotating_cylinder/ppo_controller.py index 5ef00e0..4a9dc3c 100644 --- a/closed_loop_AFC/rotating_cylinder/ppo_controller.py +++ b/closed_loop_AFC/rotating_cylinder/ppo_controller.py @@ -390,9 +390,11 @@ def parse_args(): logger.error("wandb is not installed, run `pip install gymprecice[vis]`") raise err - # TRY NOT TO MODIFY: seeding + # deterministic training random.seed(args.seed) np.random.seed(args.seed) + torch.manual_seed(args.seed) + torch.backends.cudnn.deterministic = args.torch_deterministic def make_env(options, idx, wrappers=None): def _make_env():