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 weights_only=True to all torch.load calls #86

Merged
merged 1 commit into from
Nov 18, 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
14 changes: 11 additions & 3 deletions neural_lam/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def load_dataset_stats(dataset_name, device="cpu"):

def loads_file(fn):
return torch.load(
os.path.join(static_dir_path, fn), map_location=device
os.path.join(static_dir_path, fn),
map_location=device,
weights_only=True,
)

data_mean = loads_file("parameter_mean.pt") # (d_features,)
Expand All @@ -42,7 +44,9 @@ def load_static_data(dataset_name, device="cpu"):

def loads_file(fn):
return torch.load(
os.path.join(static_dir_path, fn), map_location=device
os.path.join(static_dir_path, fn),
map_location=device,
weights_only=True,
)

# Load border mask, 1. if node is part of border, else 0.
Expand Down Expand Up @@ -116,7 +120,11 @@ def load_graph(graph_name, device="cpu"):
graph_dir_path = os.path.join("graphs", graph_name)

def loads_file(fn):
return torch.load(os.path.join(graph_dir_path, fn), map_location=device)
return torch.load(
os.path.join(graph_dir_path, fn),
map_location=device,
weights_only=True,
)

# Load edges (edge_index)
m2m_edge_index = BufferList(
Expand Down
Loading