Files
candle/candle-core/tests/pth.py
2024-02-06 21:17:33 +01:00

11 lines
242 B
Python

import torch
from collections import OrderedDict
# Write a trivial tensor to a pt file
a= torch.tensor([[1,2,3,4], [5,6,7,8]])
o = OrderedDict()
o["test"] = a
torch.save(o, "test.pt")
torch.save({"model_state_dict": o}, "test_with_key.pt")