Skip to content

Different way of saving models #236

@niekdejonge

Description

@niekdejonge

We now save models using torch.save() and torch.load(). This is the recommended way for pytorch as far as I could find: https://pytorch.org/tutorials/beginner/saving_loading_models.html#:~:text=Saving%20the%20model%27s%20state_dict%20with,recommended%20method%20for%20saving%20models.
However, this method relies on pickle which poses a security issue. This is now picked up by sonarcloud as security issue https://sonarcloud.io/project/security_hotspots?id=matchms_ms2deepscore&branch=cleaning_refactoring_232&issueStatuses=OPEN%2CCONFIRMED&sinceLeakPeriod=true&tab=code
One solution for reducing the risk would be only loading the weights (see pytorch/pytorch#52181 ), however we need the settings too, so this is not really an option unless we separately store the settings in a json file, which I don't think is ideal.

So I currently don't see a good alternative for saving and loading. @florian-huber do you know an alternative way, that is common to use for pytorch?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions