Commit 1188b56d authored by Yuxin Wu's avatar Yuxin Wu

fix resnet training

parent efbf256e
......@@ -93,7 +93,7 @@ class Model(ModelDesc):
50: ([3,4,6,3], bottleneck),
101: ([3,4,23,3], bottleneck)
}
defs, block_func = cfg[50]
defs, block_func = cfg[34]
with argscope(Conv2D, nl=tf.identity, use_bias=False,
W_init=variance_scaling_initializer(mode='FAN_OUT')):
......@@ -119,8 +119,7 @@ class Model(ModelDesc):
add_moving_summary(tf.reduce_mean(wrong, name='train-error-top5'))
# weight decay on all W of fc layers
wd_w = tf.train.exponential_decay(1e-4, get_global_step_var(),
200000, 0.7, True)
wd_w = 1e-4
wd_cost = tf.mul(wd_w, regularize_cost('.*/W', tf.nn.l2_loss), name='l2_regularize_loss')
add_moving_summary(loss, wd_cost)
self.cost = tf.add_n([loss, wd_cost], name='cost')
......@@ -135,7 +134,8 @@ def get_data(train_or_test):
image_std = np.array([0.229, 0.224, 0.225], dtype='float32')
if isTrain:
def resize_func(img):
class Resize(imgaug.ImageAugmentor):
def _augment(self, img, _):
# crop 8%~100% of the original image
# See `Going Deeper with Convolutions` by Google.
h, w = img.shape[:2]
......@@ -157,7 +157,7 @@ def get_data(train_or_test):
return out
augmentors = [
imgaug.MapImage(resize_func),
Resize(),
imgaug.RandomOrderAug(
[imgaug.Brightness(30, clip=False),
imgaug.Contrast((0.8, 1.2), clip=False),
......@@ -228,8 +228,6 @@ def eval_on_ILSVRC12(model_file, data_dir):
acc5.feed(o[1].sum(), batch_size)
print("Top1 Error: {}".format(acc1.ratio))
print("Top5 Error: {}".format(acc5.ratio))
print("Top1 Error: {}".format(acc1.ratio))
print("Top5 Error: {}".format(acc5.ratio))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment