Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
ed812bdb
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ed812bdb
编写于
5月 16, 2018
作者:
K
kolinwei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
benchmark script support multi card train
上级
48ac9780
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
14 deletion
+18
-14
benchmark/fluid/mnist.py
benchmark/fluid/mnist.py
+6
-6
benchmark/fluid/resnet.py
benchmark/fluid/resnet.py
+6
-4
benchmark/fluid/vgg.py
benchmark/fluid/vgg.py
+6
-4
未找到文件。
benchmark/fluid/mnist.py
浏览文件 @
ed812bdb
...
...
@@ -159,6 +159,7 @@ def run_benchmark(model, args):
paddle
.
dataset
.
mnist
.
train
(),
batch_size
=
args
.
batch_size
)
accuracy
=
fluid
.
metrics
.
Accuracy
()
train_exe
=
fluid
.
ParallelExecutor
(
use_cuda
=
True
,
loss_name
=
avg_cost
.
name
)
iters
,
num_samples
,
start_time
=
0
,
0
,
time
.
time
()
for
pass_id
in
range
(
args
.
pass_num
):
accuracy
.
reset
()
...
...
@@ -175,17 +176,16 @@ def run_benchmark(model, args):
y_data
=
np
.
array
(
map
(
lambda
x
:
x
[
1
],
data
)).
astype
(
"int64"
)
y_data
=
y_data
.
reshape
([
len
(
y_data
),
1
])
outs
=
exe
.
run
(
fluid
.
default_main_program
(),
outs
=
train_exe
.
run
(
feed
=
{
"pixel"
:
img_data
,
"label"
:
y_data
},
fetch_list
=
[
avg_cost
,
batch_acc
,
batch_size_tensor
]
fetch_list
=
[
avg_cost
.
name
,
batch_acc
.
name
,
batch_size_tensor
.
name
]
)
# The accuracy is the accumulation of batches, but not the current batch.
accuracy
.
update
(
value
=
outs
[
1
],
weight
=
outs
[
2
]
)
accuracy
.
update
(
value
=
np
.
array
(
np
.
mean
(
outs
[
1
])),
weight
=
np
.
mean
(
np
.
array
(
outs
[
2
]))
)
iters
+=
1
num_samples
+=
len
(
y_data
)
loss
=
np
.
array
(
outs
[
0
]
)
acc
=
np
.
array
(
outs
[
1
]
)
loss
=
np
.
mean
(
np
.
array
(
outs
[
0
])
)
acc
=
np
.
mean
(
np
.
array
(
outs
[
1
])
)
train_losses
.
append
(
loss
)
train_accs
.
append
(
acc
)
print
(
"Pass: %d, Iter: %d, Loss: %f, Accuracy: %f"
%
...
...
benchmark/fluid/resnet.py
浏览文件 @
ed812bdb
...
...
@@ -241,6 +241,7 @@ def run_benchmark(model, args):
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
fluid
.
default_startup_program
())
accuracy
=
fluid
.
average
.
WeightedAverage
()
train_exe
=
fluid
.
ParallelExecutor
(
use_cuda
=
True
,
loss_name
=
avg_cost
.
name
)
if
args
.
use_fake_data
:
data
=
train_reader
().
next
()
image
=
np
.
array
(
map
(
lambda
x
:
x
[
0
].
reshape
(
dshape
),
data
)).
astype
(
...
...
@@ -264,14 +265,15 @@ def run_benchmark(model, args):
data
)).
astype
(
'float32'
)
label
=
np
.
array
(
map
(
lambda
x
:
x
[
1
],
data
)).
astype
(
'int64'
)
label
=
label
.
reshape
([
-
1
,
1
])
loss
,
acc
,
weight
=
exe
.
run
(
fluid
.
default_main_program
(),
loss
,
acc
,
weight
=
train_exe
.
run
(
feed
=
{
'data'
:
image
,
'label'
:
label
},
fetch_list
=
[
avg_cost
,
batch_acc
,
batch_size_tensor
])
fetch_list
=
[
avg_cost
.
name
,
batch_acc
.
name
,
batch_size_tensor
.
name
])
iters
+=
1
num_samples
+=
len
(
label
)
accuracy
.
add
(
value
=
acc
,
weight
=
weight
)
accuracy
.
add
(
value
=
np
.
array
(
np
.
mean
(
acc
)),
weight
=
np
.
mean
(
weight
))
loss
=
np
.
mean
(
np
.
array
(
loss
))
acc
=
np
.
mean
(
np
.
array
(
acc
))
train_losses
.
append
(
loss
)
train_accs
.
append
(
acc
)
print
(
"Pass: %d, Iter: %d, Loss: %f, Accuracy: %f"
%
...
...
benchmark/fluid/vgg.py
浏览文件 @
ed812bdb
...
...
@@ -169,6 +169,7 @@ def main():
iters
,
num_samples
,
start_time
=
0
,
0
,
time
.
time
()
accuracy
=
fluid
.
average
.
WeightedAverage
()
train_exe
=
fluid
.
ParallelExecutor
(
use_cuda
=
True
,
loss_name
=
avg_cost
.
name
)
for
pass_id
in
range
(
args
.
pass_num
):
accuracy
.
reset
()
train_accs
=
[]
...
...
@@ -184,14 +185,15 @@ def main():
y_data
=
np
.
array
(
map
(
lambda
x
:
x
[
1
],
data
)).
astype
(
"int64"
)
y_data
=
y_data
.
reshape
([
-
1
,
1
])
loss
,
acc
,
weight
=
exe
.
run
(
fluid
.
default_main_program
(),
loss
,
acc
,
weight
=
train_exe
.
run
(
feed
=
{
"pixel"
:
img_data
,
"label"
:
y_data
},
fetch_list
=
[
avg_cost
,
batch_acc
,
batch_size_tensor
])
accuracy
.
add
(
value
=
acc
,
weight
=
weight
)
fetch_list
=
[
avg_cost
.
name
,
batch_acc
.
name
,
batch_size_tensor
.
name
])
accuracy
.
add
(
value
=
np
.
array
(
np
.
mean
(
acc
)),
weight
=
np
.
mean
(
weight
)
)
iters
+=
1
num_samples
+=
len
(
y_data
)
loss
=
np
.
mean
(
np
.
array
(
loss
))
acc
=
np
.
mean
(
np
.
array
(
acc
))
print
(
"Pass = %d, Iter = %d, Loss = %f, Accuracy = %f"
%
(
pass_id
,
iters
,
loss
,
acc
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录