Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
fix code style and copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
qingqing01 committed Jan 2, 2017
1 parent 2f38be3 commit 3ef14f0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
13 changes: 3 additions & 10 deletions image_classification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Alex Krizhevsky在2012年ILSVRC提出的CNN模型 \[[9](#参考文献)\] 取得
- Droupout \[[10](#参考文献)\] : 在模型训练阶段随机让一些隐层节点权重不工作,提高网络的泛化能力
,一定程度上防止过拟合。

除过上面这些基本的组件外,另一个非常值得一提是2015年提出的Batch Normalization(BN)算法 \[[14](#参考文献)\],作者指出在训练过程中由于每层参数不断更新,会导致下一次输入分布发生变化,这样导致训练过程需要精心设计超参数。而BN算法是每个batch对网络中的每一层的特征做归一化,使得每层分布相对稳定,起到一定的正则作用,同时也弱化了超参数的设计,经过实验证明,BN加速了训练过程。BN在后来较深的模型中被广泛使用。
传统CNN包含卷积层、全连接层等组件,采用softmax多类别分类器和多类交叉熵损失函数。另一个非常值得一提是2015年提出的Batch Normalization(BN)算法 \[[14](#参考文献)\],作者指出在训练过程中由于每层参数不断更新,会导致下一次输入分布发生变化,这样导致训练过程需要精心设计超参数。而BN算法是每个batch对网络中的每一层的特征做归一化,使得每层分布相对稳定,起到一定的正则作用,同时也弱化了超参数的设计,经过实验证明,BN加速了训练过程。BN在后来较深的模型中被广泛使用。

接下来我们主要介绍VGG,GooleNet和ResNet网络结构。

Expand Down Expand Up @@ -481,17 +481,10 @@ python classify.py --job=extract --model=output/pass-00299 --data=image/dog.png

[13] Lin, M., Chen, Q., and Yan, S. Network in network. In Proc. ICLR, 2014.

[14] S. Ioffe and C. Szegedy. Batch normalization: Accelerating deep
network training by reducing internal covariate shift. In ICML, 2015.
[14] S. Ioffe and C. Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In ICML, 2015.

[15] K. He, X. Zhang, S. Ren, J. Sun. Deep Residual Learning for Image Recognition. CVPR 2016.

[16] Szegedy, C., Vanhoucke, V., Ioffe, S., Shlens, J., Wojna, Z.: Rethinking the incep-tion architecture for computer vision. In: CVPR. (2016).

[17] Szegedy, C., Ioffe, S., Vanhoucke, V.: Inception-v4, inception-resnet and the impact of residual connections on learning. arXiv:1602.07261 (2016).





2 changes: 1 addition & 1 deletion image_classification/classify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2016 Baidu, Inc. All Rights Reserved
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
23 changes: 20 additions & 3 deletions image_classification/data/cifar10.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import numpy as np
import cPickle
Expand All @@ -7,22 +21,24 @@
HEIGHT = 32
WIDTH = 32


def create_mean(dataset):
if not os.path.isfile("mean.meta"):
mean = np.zeros(CHANNEL * HEIGHT * WIDTH)
num = 0
for f in dataset:
batch = np.load(f)
mean += batch['data'].sum(0)
mean += batch['data'].sum(0)
num += len(batch['data'])
mean /= num
print mean.size
data = {"mean": mean, "size": mean.size}
cPickle.dump(data, open("mean.meta", 'w'), protocol=cPickle.HIGHEST_PROTOCOL)
cPickle.dump(
data, open("mean.meta", 'w'), protocol=cPickle.HIGHEST_PROTOCOL)


def create_data():
train_set = [DATA + "/data_batch_%d" % (i + 1) for i in xrange(0,5)]
train_set = [DATA + "/data_batch_%d" % (i + 1) for i in xrange(0, 5)]
test_set = [DATA + "/test_batch"]

# create mean values
Expand All @@ -39,5 +55,6 @@ def create_data():
open("test.txt", "w").write("\n".join(test))
open("test.list", "w").write("\n".join(["data/test.txt"]))


if __name__ == '__main__':
create_data()
3 changes: 2 additions & 1 deletion image_classification/data/get_data.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2016 Baidu, Inc. All Rights Reserved
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -e

wget https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
tar zxf cifar-10-python.tar.gz
rm cifar-10-python.tar.gz
Expand Down

0 comments on commit 3ef14f0

Please sign in to comment.