Sure!
Here is a function how I save the model / weights.
def save_models(epoch):
Remove the last checkpoint
path = os.path.join(RUNS_PATH, exp_name)
files = os.listdir(path)
for file in files:
if file.endswith(’.model’):
os.remove(os.path.join(path, file))
Save new checkpoint
torch.save(model.state_dict(), os.path.join(path, “CNN_model_epoch_{}.model”.format(str(epoch))))
print(“Chekcpoint saved”)
Note that I already showed how I load the model / weights.
Thanks,
Or
‫בתאריך יום ה׳, 14 במרץ 2019 ב-15:25 מאת ‪Imanol Luengo via PyTorch Forums‬‏ <‪noreply@discuss.pytorch.org‬‏>:‬