Skip to content

Commit ea4483f

Browse files
committed
[Chore] set weights_only as False during loading for upcoming PyTorch 2.6
1 parent e378ddc commit ea4483f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: rl4co/models/rl/reinforce/reinforce.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ def load_from_checkpoint(
201201
loaded.setup()
202202
loaded.post_setup_hook()
203203
# load baseline state dict
204-
state_dict = torch.load(checkpoint_path, map_location=map_location)[
205-
"state_dict"
206-
]
204+
state_dict = torch.load(
205+
checkpoint_path, map_location=map_location, weights_only=False
206+
)["state_dict"]
207207
# get only baseline parameters
208208
state_dict = {k: v for k, v in state_dict.items() if "baseline" in k}
209209
state_dict = {k.replace("baseline.", "", 1): v for k, v in state_dict.items()}

Diff for: rl4co/models/zoo/polynet/model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(
9191
logging.info(
9292
f"Trying to load weights from baseline model {base_model_checkpoint_path}"
9393
)
94-
checkpoint = torch.load(base_model_checkpoint_path)
94+
checkpoint = torch.load(base_model_checkpoint_path, weights_only=False)
9595
state_dict = checkpoint["state_dict"]
9696
state_dict = {k.replace("policy.", "", 1): v for k, v in state_dict.items()}
9797
policy.load_state_dict(state_dict, strict=False)

0 commit comments

Comments
 (0)