Skip to content

torch 2.6 ( weights_only argument in torch.load from False to True) #5

Description

@hooman-sarv

I try to save model and then load it. Is there any update in new torch version? or should I modify your main.py file?
in previous torch version is work without problem.
I also test these solutions :

model = torch.load('pyEDA/pyEDA/checkpoint.t7', weights_only=False)
or

model.load_state_dict(torch.load("autoencoder_weights.pth"))

(1) In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
(2) Alternatively, to load with weights_only=True please check the recommended steps in the following error message.
WeightsUnpickler error: Unsupported global: GLOBAL pyEDA.pyEDA.autoencoder.AE was not an allowed global by default. Please use torch.serialization.add_safe_globals([AE]) or the torch.serialization.safe_globals([AE]) context manager to allowlist this global if you trust this class/function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions