Computes and stores the average and current value Imported from https://github.com/pytorch/examples/blob/master/imagenet/main.py#L247-L262
| 32 | |
| 33 | |
| 34 | class AverageMeter(object): |
| 35 | """Computes and stores the average and current value |
| 36 | Imported from https://github.com/pytorch/examples/blob/master/imagenet/main.py#L247-L262 |
| 37 | """ |
| 38 | def __init__(self): |
| 39 | self.reset() |
| 40 | |
| 41 | def reset(self): |
| 42 | self.val = 0 |
| 43 | self.avg = 0 |
| 44 | self.sum = 0 |
| 45 | self.count = 0 |
| 46 | |
| 47 | def update(self, val, n=1): |
| 48 | self.val = val |
| 49 | self.sum += val * n |
| 50 | self.count += n |
| 51 | self.avg = self.sum / self.count |
| 52 | |
| 53 | |
| 54 | def get_temperature(iteration, epoch, iter_per_epoch, temp_epoch=10, temp_init=30.0): |