add torchtools

This commit is contained in:
KaiyangZhou 2018-07-04 10:32:32 +01:00
parent 9dd1d48d3c
commit ade721922c

10
utils/torchtools.py Normal file
View File

@ -0,0 +1,10 @@
from __future__ import absolute_import
from __future__ import division
import torch
def adjust_learning_rate(optimizer, base_lr, epoch, stepsize, gamma=0.1):
lr = base_lr * (gamma ** (epoch // stepsize))
for param_group in optimizer.param_groups:
param_group['lr'] = lr