Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OPTHREE
Paddle
提交
0f7c4071
P
Paddle
项目概览
OPTHREE
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0f7c4071
编写于
9月 21, 2017
作者:
T
tensor-tang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add vgg and script for mkldnn benchmark
上级
ed27a3be
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
150 addition
and
1 deletion
+150
-1
benchmark/paddle/image/provider.py
benchmark/paddle/image/provider.py
+1
-1
benchmark/paddle/image/run.mkldnn.sh
benchmark/paddle/image/run.mkldnn.sh
+46
-0
benchmark/paddle/image/vgg.py
benchmark/paddle/image/vgg.py
+103
-0
未找到文件。
benchmark/paddle/image/provider.py
浏览文件 @
0f7c4071
...
...
@@ -22,5 +22,5 @@ def initHook(settings, height, width, color, num_class, **kwargs):
def
process
(
settings
,
file_list
):
for
i
in
xrange
(
1024
):
img
=
np
.
random
.
rand
(
1
,
settings
.
data_size
).
reshape
(
-
1
,
1
).
flatten
()
lab
=
random
.
randint
(
0
,
settings
.
num_class
)
lab
=
random
.
randint
(
0
,
settings
.
num_class
-
1
)
yield
img
.
astype
(
'float32'
),
int
(
lab
)
benchmark/paddle/image/run.mkldnn.sh
0 → 100755
浏览文件 @
0f7c4071
set
-e
function
train
()
{
topology
=
$1
bs
=
$2
thread
=
1
if
[
$3
]
;
then
thread
=
$3
fi
if
[
$thread
-eq
1
]
;
then
use_mkldnn
=
1
log
=
"logs/
${
topology
}
-mkldnn-
${
bs
}
.log"
else
use_mkldnn
=
0
log
=
"logs/
${
topology
}
-
${
thread
}
mklml-
${
bs
}
.log"
fi
args
=
"batch_size=
${
bs
}
"
config
=
"
${
topology
}
.py"
paddle train
--job
=
time
\
--config
=
$config
\
--use_mkldnn
=
$use_mkldnn
\
--use_gpu
=
False
\
--trainer_count
=
$thread
\
--log_period
=
10
\
--test_period
=
100
\
--config_args
=
$args
\
2>&1 |
tee
${
log
}
}
if
[
!
-d
"train.list"
]
;
then
echo
" "
>
train.list
fi
if
[
!
-d
"logs"
]
;
then
mkdir
logs
fi
#========= mkldnn =========#
# vgg
train vgg 64
train vgg 128
train vgg 256
#========== mklml ===========#
train vgg 64 16
train vgg 128 16
train vgg 256 16
benchmark/paddle/image/vgg.py
0 → 100644
浏览文件 @
0f7c4071
#!/usr/bin/env python
from
paddle.trainer_config_helpers
import
*
height
=
224
width
=
224
num_class
=
1000
batch_size
=
get_config_arg
(
'batch_size'
,
int
,
64
)
layer_num
=
get_config_arg
(
'layer_num'
,
int
,
16
)
args
=
{
'height'
:
height
,
'width'
:
width
,
'color'
:
True
,
'num_class'
:
num_class
}
define_py_data_sources2
(
"train.list"
,
None
,
module
=
"provider"
,
obj
=
"process"
,
args
=
args
)
settings
(
batch_size
=
batch_size
,
learning_rate
=
0.01
/
batch_size
,
learning_method
=
MomentumOptimizer
(
0.9
),
regularization
=
L2Regularization
(
0.0005
*
batch_size
))
img
=
data_layer
(
name
=
'image'
,
size
=
height
*
width
*
3
)
def
vgg_network
(
vgg_num
=
3
):
tmp
=
img_conv_group
(
input
=
img
,
num_channels
=
3
,
conv_padding
=
1
,
conv_num_filter
=
[
64
,
64
],
conv_filter_size
=
3
,
conv_act
=
ReluActivation
(),
pool_size
=
2
,
pool_stride
=
2
,
pool_type
=
MaxPooling
())
tmp
=
img_conv_group
(
input
=
tmp
,
conv_num_filter
=
[
128
,
128
],
conv_padding
=
1
,
conv_filter_size
=
3
,
conv_act
=
ReluActivation
(),
pool_stride
=
2
,
pool_type
=
MaxPooling
(),
pool_size
=
2
)
channels
=
[]
for
i
in
range
(
vgg_num
):
channels
.
append
(
256
)
tmp
=
img_conv_group
(
input
=
tmp
,
conv_num_filter
=
channels
,
conv_padding
=
1
,
conv_filter_size
=
3
,
conv_act
=
ReluActivation
(),
pool_stride
=
2
,
pool_type
=
MaxPooling
(),
pool_size
=
2
)
channels
=
[]
for
i
in
range
(
vgg_num
):
channels
.
append
(
512
)
tmp
=
img_conv_group
(
input
=
tmp
,
conv_num_filter
=
channels
,
conv_padding
=
1
,
conv_filter_size
=
3
,
conv_act
=
ReluActivation
(),
pool_stride
=
2
,
pool_type
=
MaxPooling
(),
pool_size
=
2
)
tmp
=
img_conv_group
(
input
=
tmp
,
conv_num_filter
=
channels
,
conv_padding
=
1
,
conv_filter_size
=
3
,
conv_act
=
ReluActivation
(),
pool_stride
=
2
,
pool_type
=
MaxPooling
(),
pool_size
=
2
)
tmp
=
fc_layer
(
input
=
tmp
,
size
=
4096
,
act
=
ReluActivation
(),
layer_attr
=
ExtraAttr
(
drop_rate
=
0.5
))
tmp
=
fc_layer
(
input
=
tmp
,
size
=
4096
,
act
=
ReluActivation
(),
layer_attr
=
ExtraAttr
(
drop_rate
=
0.5
))
return
fc_layer
(
input
=
tmp
,
size
=
num_class
,
act
=
SoftmaxActivation
())
if
layer_num
==
16
:
vgg
=
vgg_network
(
3
)
elif
layer_num
==
19
:
vgg
=
vgg_network
(
4
)
else
:
print
(
"Wrong layer number."
)
lab
=
data_layer
(
'label'
,
num_class
)
loss
=
cross_entropy
(
input
=
vgg
,
label
=
lab
)
outputs
(
loss
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录