From d7d1ae5a9eb8a02ea63af2e55fb782ab74e2a1a9 Mon Sep 17 00:00:00 2001 From: wwhu Date: Fri, 2 Jun 2017 14:00:09 +0800 Subject: [PATCH] minor revision --- image_classification/README.md | 5 ++++ image_classification/googlenet.py | 50 ------------------------------- image_classification/resnet.py | 2 -- 3 files changed, 5 insertions(+), 52 deletions(-) diff --git a/image_classification/README.md b/image_classification/README.md index 0010fe5b..39167fa1 100644 --- a/image_classification/README.md +++ b/image_classification/README.md @@ -123,6 +123,11 @@ optimizer = paddle.optimizer.Momentum( learning_rate_schedule="discexp", ) ``` +通过 `learning_rate_decay_a` (简写$a$) 、`learning_rate_decay_b` (简写$b$) 和 `learning_rate_schedule` 指定学习率调整策略,这里采用离散指数的方式调节学习率,计算公式如下, $n$ 代表已经处理过的累计总样本数,$lr_{0}$ 即为参数里设置的 `learning_rate`。 + +$$ lr = lr_{0} * a^ {\lfloor \frac{n}{ b}\rfloor} $$ + + ### 定义数据读取方法和事件处理程序 读取数据时需要分别指定训练集和验证集的图像列表文件,这里假设这两个文件分别为`train.list`和`val.list`。 diff --git a/image_classification/googlenet.py b/image_classification/googlenet.py index 2e4153cc..e21a0360 100644 --- a/image_classification/googlenet.py +++ b/image_classification/googlenet.py @@ -3,56 +3,6 @@ import paddle.v2 as paddle __all__ = ['googlenet'] -def inception(name, input, channels, filter1, filter3R, filter3, filter5R, - filter5, proj): - cov1 = paddle.layer.conv_projection( - input=input, - filter_size=1, - num_channels=channels, - num_filters=filter1, - stride=1, - padding=0) - - cov3r = paddle.layer.img_conv( - name=name + '_3r', - input=input, - filter_size=1, - num_channels=channels, - num_filters=filter3R, - stride=1, - padding=0) - cov3 = paddle.layer.conv_projection( - input=cov3r, filter_size=3, num_filters=filter3, stride=1, padding=1) - - cov5r = paddle.layer.img_conv( - name=name + '_5r', - input=input, - filter_size=1, - num_channels=channels, - num_filters=filter5R, - stride=1, - padding=0) - cov5 = paddle.layer.conv_projection( - input=cov5r, filter_size=5, num_filters=filter5, stride=1, padding=2) - - pool1 = paddle.layer.img_pool( - name=name + '_max', - input=input, - pool_size=3, - num_channels=channels, - stride=1, - padding=1) - covprj = paddle.layer.conv_projection( - input=pool1, filter_size=1, num_filters=proj, stride=1, padding=0) - - cat = paddle.layer.concat( - name=name, - input=[cov1, cov3, cov5, covprj], - bias_attr=True, - act=paddle.activation.Relu()) - return cat - - def inception2(name, input, channels, filter1, filter3R, filter3, filter5R, filter5, proj): cov1 = paddle.layer.img_conv( diff --git a/image_classification/resnet.py b/image_classification/resnet.py index 7ef551b3..63bc4409 100644 --- a/image_classification/resnet.py +++ b/image_classification/resnet.py @@ -31,7 +31,6 @@ def shortcut(input, n_out, stride, b_projection): def basicblock(input, ch_out, stride, b_projection): - # TODO: bug fix for ch_in = input.num_filters conv1 = conv_bn_layer(input, ch_out, 3, stride, 1) conv2 = conv_bn_layer(conv1, ch_out, 3, 1, 1, paddle.activation.Linear()) short = shortcut(input, ch_out, stride, b_projection) @@ -40,7 +39,6 @@ def basicblock(input, ch_out, stride, b_projection): def bottleneck(input, ch_out, stride, b_projection): - # TODO: bug fix for ch_in = input.num_filters conv1 = conv_bn_layer(input, ch_out, 1, stride, 0) conv2 = conv_bn_layer(conv1, ch_out, 3, 1, 1) conv3 = conv_bn_layer(conv2, ch_out * 4, 1, 1, 0, -- GitLab