Загрузка
See Layout Control for more advanced tools to manipulate a checkpoint.
obj (object) – saved object
f (str | PathLike[str] | IO[bytes]) – a file-like object (has to implement write and flush) or a string or os.PathLike object containing a file name
pickle_module (Any) – module used for pickling metadata and objects
pickle_protocol (int) – can be specified to override the default protocol
>>> # Save to file
>>> x = torch.tensor([0, 1, 2, 3, 4])
>>> torch.save(x, "tensor.pt")
>>> # Save to io.BytesIO buffer
>>> buffer = io.BytesIO()
>>> torch.save(x, buffer)