INNER CODE UNIT · Python
save_checkpoint
adobe/antialiased-cnns · main.py:665
def save_checkpoint(state, is_best, epoch, out_dir='./'):
torch.save(state, os.path.join(out_dir,'checkpoint.pth.tar'))
if(epoch % 10 == 0):
torch.save(state, os.path.join(out_dir,'checkpoint_%03d.pth.tar'%epoch))
if is_best:
shutil.copyfile(os.path.join(out_dir,'checkpoint.pth.tar'), os.path.join(out_dir,'model_best.pth.tar'))
class AverageMeter(object):
"""Computes and stores the average and current value"""
def __init__(self):
self.reset()
def reset(self):
self.val = 0
self.avg = 0
self.sum = 0
self.count = 0