diff --git a/image_classification/README.md b/image_classification/README.md index 0010fe5b0a106b3be0d31e91877bd99d3a55f9e8..39167fa19efa13b4c101227e1111269e63a7ec55 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 2e4153ccb66291625360a21df746e374d92b6ed4..e21a0360249bd386d77ce7c9ef639a45347b19a0 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 7ef551b3bb7ff946d3a316b066fd4c5f7c59ecbe..63bc4409b79f2d77e13efb3ce3b6e51ec6973065 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,