Skip to content

Commit 98c3cc1

Browse files
committed
fix torch.save to PyTorch 2.6.0
1 parent ef2004f commit 98c3cc1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bindsnet/network/network.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def load(file_name: str, map_location: str = "cpu", learning: bool = None) -> "N
1919
:param learning: Whether to load with learning enabled. Default loads value from
2020
disk.
2121
"""
22-
network = torch.load(open(file_name, "rb"), map_location=map_location)
22+
network = torch.load(open(file_name, "rb"), map_location=map_location, weights_only=False)
2323
if learning is not None and "learning" in vars(network):
2424
network.learning = learning
2525

@@ -191,6 +191,7 @@ def save(self, file_name: str) -> None:
191191
# Save the network to disk.
192192
network.save(str(Path.home()) + '/network.pt')
193193
"""
194+
torch.serialization.add_safe_globals([self])
194195
torch.save(self, open(file_name, "wb"))
195196

196197
def clone(self) -> "Network":

0 commit comments

Comments
 (0)