Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
a5aac614
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a5aac614
编写于
11月 30, 2017
作者:
T
tensor-tang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
skip cost when inference
上级
849bf9d0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
58 addition
and
21 deletion
+58
-21
benchmark/paddle/image/googlenet.py
benchmark/paddle/image/googlenet.py
+15
-5
benchmark/paddle/image/provider.py
benchmark/paddle/image/provider.py
+10
-4
benchmark/paddle/image/resnet.py
benchmark/paddle/image/resnet.py
+19
-8
benchmark/paddle/image/vgg.py
benchmark/paddle/image/vgg.py
+14
-4
未找到文件。
benchmark/paddle/image/googlenet.py
浏览文件 @
a5aac614
...
@@ -6,8 +6,15 @@ width = 224
...
@@ -6,8 +6,15 @@ width = 224
num_class
=
1000
num_class
=
1000
batch_size
=
get_config_arg
(
'batch_size'
,
int
,
128
)
batch_size
=
get_config_arg
(
'batch_size'
,
int
,
128
)
use_gpu
=
get_config_arg
(
'use_gpu'
,
bool
,
True
)
use_gpu
=
get_config_arg
(
'use_gpu'
,
bool
,
True
)
is_infer
=
get_config_arg
(
"is_infer"
,
bool
,
False
)
args
=
{
'height'
:
height
,
'width'
:
width
,
'color'
:
True
,
'num_class'
:
num_class
}
args
=
{
'height'
:
height
,
'width'
:
width
,
'color'
:
True
,
'num_class'
:
num_class
,
'is_infer'
:
is_infer
}
define_py_data_sources2
(
define_py_data_sources2
(
"train.list"
,
"test.list"
,
module
=
"provider"
,
obj
=
"process"
,
args
=
args
)
"train.list"
,
"test.list"
,
module
=
"provider"
,
obj
=
"process"
,
args
=
args
)
...
@@ -146,7 +153,6 @@ def inception(name, input, channels, \
...
@@ -146,7 +153,6 @@ def inception(name, input, channels, \
return
cat
return
cat
lab
=
data_layer
(
name
=
"label"
,
size
=
1000
)
data
=
data_layer
(
name
=
"input"
,
size
=
3
*
height
*
width
)
data
=
data_layer
(
name
=
"input"
,
size
=
3
*
height
*
width
)
# stage 1
# stage 1
...
@@ -224,6 +230,10 @@ pool5 = img_pool_layer(
...
@@ -224,6 +230,10 @@ pool5 = img_pool_layer(
dropout
=
dropout_layer
(
name
=
"dropout"
,
input
=
pool5
,
dropout_rate
=
0.4
)
dropout
=
dropout_layer
(
name
=
"dropout"
,
input
=
pool5
,
dropout_rate
=
0.4
)
out3
=
fc_layer
(
out3
=
fc_layer
(
name
=
"output3"
,
input
=
dropout
,
size
=
1000
,
act
=
SoftmaxActivation
())
name
=
"output3"
,
input
=
dropout
,
size
=
1000
,
act
=
SoftmaxActivation
())
loss3
=
cross_entropy
(
name
=
'loss3'
,
input
=
out3
,
label
=
lab
)
outputs
(
loss3
)
if
is_infer
:
outputs
(
out3
)
else
:
lab
=
data_layer
(
name
=
"label"
,
size
=
num_class
)
loss3
=
cross_entropy
(
name
=
'loss3'
,
input
=
out3
,
label
=
lab
)
outputs
(
loss3
)
benchmark/paddle/image/provider.py
浏览文件 @
a5aac614
...
@@ -13,8 +13,11 @@ def initHook(settings, height, width, color, num_class, **kwargs):
...
@@ -13,8 +13,11 @@ def initHook(settings, height, width, color, num_class, **kwargs):
settings
.
data_size
=
settings
.
height
*
settings
.
width
*
3
settings
.
data_size
=
settings
.
height
*
settings
.
width
*
3
else
:
else
:
settings
.
data_size
=
settings
.
height
*
settings
.
width
settings
.
data_size
=
settings
.
height
*
settings
.
width
settings
.
is_infer
=
kwargs
.
get
(
'is_infer'
,
False
)
settings
.
slots
=
[
dense_vector
(
settings
.
data_size
),
integer_value
(
1
)]
if
settings
.
is_infer
:
settings
.
slots
=
[
dense_vector
(
settings
.
data_size
)]
else
:
settings
.
slots
=
[
dense_vector
(
settings
.
data_size
),
integer_value
(
1
)]
@
provider
(
@
provider
(
...
@@ -22,5 +25,8 @@ def initHook(settings, height, width, color, num_class, **kwargs):
...
@@ -22,5 +25,8 @@ def initHook(settings, height, width, color, num_class, **kwargs):
def
process
(
settings
,
file_list
):
def
process
(
settings
,
file_list
):
for
i
in
xrange
(
1024
):
for
i
in
xrange
(
1024
):
img
=
np
.
random
.
rand
(
1
,
settings
.
data_size
).
reshape
(
-
1
,
1
).
flatten
()
img
=
np
.
random
.
rand
(
1
,
settings
.
data_size
).
reshape
(
-
1
,
1
).
flatten
()
lab
=
random
.
randint
(
0
,
settings
.
num_class
-
1
)
if
settings
.
is_infer
:
yield
img
.
astype
(
'float32'
),
int
(
lab
)
yield
img
.
astype
(
'float32'
)
else
:
lab
=
random
.
randint
(
0
,
settings
.
num_class
-
1
)
yield
img
.
astype
(
'float32'
),
int
(
lab
)
benchmark/paddle/image/resnet.py
浏览文件 @
a5aac614
...
@@ -6,9 +6,15 @@ width = 224
...
@@ -6,9 +6,15 @@ width = 224
num_class
=
1000
num_class
=
1000
batch_size
=
get_config_arg
(
'batch_size'
,
int
,
64
)
batch_size
=
get_config_arg
(
'batch_size'
,
int
,
64
)
layer_num
=
get_config_arg
(
"layer_num"
,
int
,
50
)
layer_num
=
get_config_arg
(
"layer_num"
,
int
,
50
)
is_test
=
get_config_arg
(
"is_test"
,
bool
,
False
)
is_infer
=
get_config_arg
(
"is_infer"
,
bool
,
False
)
args
=
{
'height'
:
height
,
'width'
:
width
,
'color'
:
True
,
'num_class'
:
num_class
}
args
=
{
'height'
:
height
,
'width'
:
width
,
'color'
:
True
,
'num_class'
:
num_class
,
'is_infer'
:
is_infer
}
define_py_data_sources2
(
define_py_data_sources2
(
"train.list"
,
"test.list"
,
module
=
"provider"
,
obj
=
"process"
,
args
=
args
)
"train.list"
,
"test.list"
,
module
=
"provider"
,
obj
=
"process"
,
args
=
args
)
...
@@ -45,7 +51,10 @@ def conv_bn_layer(name,
...
@@ -45,7 +51,10 @@ def conv_bn_layer(name,
act
=
LinearActivation
(),
act
=
LinearActivation
(),
bias_attr
=
False
)
bias_attr
=
False
)
return
batch_norm_layer
(
return
batch_norm_layer
(
name
=
name
+
"_bn"
,
input
=
tmp
,
act
=
active_type
,
use_global_stats
=
is_test
)
name
=
name
+
"_bn"
,
input
=
tmp
,
act
=
active_type
,
use_global_stats
=
is_infer
)
def
bottleneck_block
(
name
,
input
,
num_filters1
,
num_filters2
):
def
bottleneck_block
(
name
,
input
,
num_filters1
,
num_filters2
):
...
@@ -207,7 +216,9 @@ elif layer_num == 152:
...
@@ -207,7 +216,9 @@ elif layer_num == 152:
else
:
else
:
print
(
"Wrong layer number."
)
print
(
"Wrong layer number."
)
lbl
=
data_layer
(
name
=
"label"
,
size
=
num_class
)
if
is_infer
:
loss
=
cross_entropy
(
name
=
'loss'
,
input
=
resnet
,
label
=
lbl
)
outputs
(
resnet
)
inputs
(
img
,
lbl
)
else
:
outputs
(
loss
)
lbl
=
data_layer
(
name
=
"label"
,
size
=
num_class
)
loss
=
cross_entropy
(
name
=
'loss'
,
input
=
resnet
,
label
=
lbl
)
outputs
(
loss
)
benchmark/paddle/image/vgg.py
浏览文件 @
a5aac614
...
@@ -6,8 +6,15 @@ width = 224
...
@@ -6,8 +6,15 @@ width = 224
num_class
=
1000
num_class
=
1000
batch_size
=
get_config_arg
(
'batch_size'
,
int
,
64
)
batch_size
=
get_config_arg
(
'batch_size'
,
int
,
64
)
layer_num
=
get_config_arg
(
'layer_num'
,
int
,
19
)
layer_num
=
get_config_arg
(
'layer_num'
,
int
,
19
)
is_infer
=
get_config_arg
(
"is_infer"
,
bool
,
False
)
args
=
{
'height'
:
height
,
'width'
:
width
,
'color'
:
True
,
'num_class'
:
num_class
}
args
=
{
'height'
:
height
,
'width'
:
width
,
'color'
:
True
,
'num_class'
:
num_class
,
'is_infer'
:
is_infer
}
define_py_data_sources2
(
define_py_data_sources2
(
"train.list"
,
"test.list"
,
module
=
"provider"
,
obj
=
"process"
,
args
=
args
)
"train.list"
,
"test.list"
,
module
=
"provider"
,
obj
=
"process"
,
args
=
args
)
...
@@ -98,6 +105,9 @@ elif layer_num == 19:
...
@@ -98,6 +105,9 @@ elif layer_num == 19:
else
:
else
:
print
(
"Wrong layer number."
)
print
(
"Wrong layer number."
)
lab
=
data_layer
(
'label'
,
num_class
)
if
is_infer
:
loss
=
cross_entropy
(
input
=
vgg
,
label
=
lab
)
outputs
(
vgg
)
outputs
(
loss
)
else
:
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录