cutcutcodec.core.nn.start.save¶
- cutcutcodec.core.nn.start.save(model: Module, weights: Path | str | bytes | None = None) Path[source]¶
Load the pretrained weights.
Parameters¶
- modeltorch.nn.Module
The model to be loaded.
- weightspathlib, optional
The path of the recorded file, with the extention .pt.xz
Returns¶
- weightspathlib.Path
The recorded file.
Examples¶
>>> import pathlib, tempfile >>> import torch >>> from cutcutcodec.core.nn.start import save >>> weights = pathlib.Path(tempfile.gettempdir()) / "tmp.pt.xz" >>> class Model(torch.nn.Module): ... def __init__(self): ... super().__init__() ... self.layer = torch.nn.Conv2d(3, 3, kernel_size=3) ... >>> model = Model() >>> save(model, weights) PosixPath('/tmp/tmp.pt.xz') >>> weights.unlink() >>>