提交 a08dc90f 编写于 作者: Y Yancey1989

polish code

上级 f66de96c
...@@ -130,41 +130,3 @@ class FastResNet(): ...@@ -130,41 +130,3 @@ class FastResNet():
short = self.shortcut(input, num_filters * 4, stride) short = self.shortcut(input, num_filters * 4, stride)
return fluid.layers.elementwise_add(x=short, y=conv2, act='relu') return fluid.layers.elementwise_add(x=short, y=conv2, act='relu')
def _model_reader_dshape_classdim(args, is_train, val_bs=None, sz=224, trn_dir="", min_scale=0.08, rect_val=False):
reader = None
if args.data_set == "imagenet":
class_dim = 1000
if args.data_format == 'NCHW':
dshape = [3, sz, sz]
else:
dshape = [sz, sz, 3]
if is_train:
reader = torchvision_reader.train(
traindir="/data/imagenet/%strain" % trn_dir, sz=sz, min_scale=min_scale)
else:
reader = torchvision_reader.test(
valdir="/data/imagenet/%svalidation" % trn_dir, bs=val_bs, sz=sz, rect_val=rect_val)
else:
raise ValueError("only support imagenet dataset.")
return None, reader, dshape, class_dim
def lr_decay(lrs, epochs, bs, total_image):
boundaries = []
values = []
import math
for idx, epoch in enumerate(epochs):
step = math.ceil(total_image * 1.0 / (bs[idx] * 8))
ratio = (lrs[idx][1] - lrs[idx][0]) / (epoch[1] - epoch[0])
lr_base = lrs[idx][0]
for s in xrange(epoch[0], epoch[1]):
if boundaries:
boundaries.append(boundaries[-1] + step)
else:
boundaries = [step]
values.append(lr_base + ratio * (s - epoch[0]))
values.append(lrs[-1])
return boundaries, values
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册