Does torch.save() overwrite the previous saved model which was saved in the same path?

Viewed 560

If i use torch.save() every epoch, does it overwrite the previous one? The task_id is '0', so the path is always './0checkpoint.pth.jar'.

def save_checkpoint(state, is_best,task_id, filename='checkpoint.pth.tar'):
    f = open('./' + task_id + filename, 'w')

    torch.save(state, './' + task_id + filename)
    if is_best:
        shutil.copyfile('./' + task_id + filename, './' + task_id + 'model_best.pth.tar')
        
    f.close()
0 Answers
Related