numpy savez保存与读取
# save
x = torch.tensor([1,2,3])
np.savez("./tmp.npz",x)
# save dict
save_inp_file = "./text.npz"
a = [torch.tensor([i]) for i in range(5)]
b = [torch.tensor([10,12]),*a]
inp_dict = {
"a":a,
"b":b,
}
np.savez(save_inp_file, dict_=inp_dict)
# load
data = np.load("./test.npz",allow_pickle=True)
print(data.files) # check
inp_dict = data['dict_'][()]