File size: 329 Bytes
978923c | 1 2 3 4 5 6 7 8 9 10 11 12 13 | import torch
from torch import nn
from safetensors.torch import load_model, save_model
a = torch.zeros((100, 100))
b = a[:1, :]
# torch.save({"b": b}, "model.bin")
# File is 41k instead of the expected 400 bytes
# In practice it could happen that you save several 10GB instead of 1GB.
save_model({"b":b}, "model.safetensors")
|