Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7792c63b
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
7792c63b
编写于
5月 17, 2018
作者:
K
kolinwei
提交者:
GitHub
5月 17, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10695 from kolinwei/develop
benchmark/fluid script支持多卡训练
上级
32a15ed9
1ee9fea3
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
26 addition
and
14 deletion
+26
-14
benchmark/fluid/mnist.py
benchmark/fluid/mnist.py
+10
-6
benchmark/fluid/resnet.py
benchmark/fluid/resnet.py
+8
-4
benchmark/fluid/vgg.py
benchmark/fluid/vgg.py
+8
-4
未找到文件。
benchmark/fluid/mnist.py
浏览文件 @
7792c63b
...
@@ -159,6 +159,7 @@ def run_benchmark(model, args):
...
@@ -159,6 +159,7 @@ def run_benchmark(model, args):
paddle
.
dataset
.
mnist
.
train
(),
batch_size
=
args
.
batch_size
)
paddle
.
dataset
.
mnist
.
train
(),
batch_size
=
args
.
batch_size
)
accuracy
=
fluid
.
metrics
.
Accuracy
()
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
()
iters
,
num_samples
,
start_time
=
0
,
0
,
time
.
time
()
for
pass_id
in
range
(
args
.
pass_num
):
for
pass_id
in
range
(
args
.
pass_num
):
accuracy
.
reset
()
accuracy
.
reset
()
...
@@ -175,17 +176,20 @@ def run_benchmark(model, args):
...
@@ -175,17 +176,20 @@ def run_benchmark(model, args):
y_data
=
np
.
array
(
map
(
lambda
x
:
x
[
1
],
data
)).
astype
(
"int64"
)
y_data
=
np
.
array
(
map
(
lambda
x
:
x
[
1
],
data
)).
astype
(
"int64"
)
y_data
=
y_data
.
reshape
([
len
(
y_data
),
1
])
y_data
=
y_data
.
reshape
([
len
(
y_data
),
1
])
outs
=
exe
.
run
(
outs
=
train_exe
.
run
(
fluid
.
default_main_program
(),
feed
=
{
"pixel"
:
img_data
,
feed
=
{
"pixel"
:
img_data
,
"label"
:
y_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.
)
# 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
iters
+=
1
num_samples
+=
len
(
y_data
)
num_samples
+=
len
(
y_data
)
loss
=
np
.
array
(
outs
[
0
]
)
loss
=
np
.
mean
(
np
.
array
(
outs
[
0
])
)
acc
=
np
.
array
(
outs
[
1
]
)
acc
=
np
.
mean
(
np
.
array
(
outs
[
1
])
)
train_losses
.
append
(
loss
)
train_losses
.
append
(
loss
)
train_accs
.
append
(
acc
)
train_accs
.
append
(
acc
)
print
(
"Pass: %d, Iter: %d, Loss: %f, Accuracy: %f"
%
print
(
"Pass: %d, Iter: %d, Loss: %f, Accuracy: %f"
%
...
...
benchmark/fluid/resnet.py
浏览文件 @
7792c63b
...
@@ -241,6 +241,7 @@ def run_benchmark(model, args):
...
@@ -241,6 +241,7 @@ def run_benchmark(model, args):
exe
=
fluid
.
Executor
(
place
)
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
fluid
.
default_startup_program
())
exe
.
run
(
fluid
.
default_startup_program
())
accuracy
=
fluid
.
average
.
WeightedAverage
()
accuracy
=
fluid
.
average
.
WeightedAverage
()
train_exe
=
fluid
.
ParallelExecutor
(
use_cuda
=
True
,
loss_name
=
avg_cost
.
name
)
if
args
.
use_fake_data
:
if
args
.
use_fake_data
:
data
=
train_reader
().
next
()
data
=
train_reader
().
next
()
image
=
np
.
array
(
map
(
lambda
x
:
x
[
0
].
reshape
(
dshape
),
data
)).
astype
(
image
=
np
.
array
(
map
(
lambda
x
:
x
[
0
].
reshape
(
dshape
),
data
)).
astype
(
...
@@ -264,14 +265,17 @@ def run_benchmark(model, args):
...
@@ -264,14 +265,17 @@ def run_benchmark(model, args):
data
)).
astype
(
'float32'
)
data
)).
astype
(
'float32'
)
label
=
np
.
array
(
map
(
lambda
x
:
x
[
1
],
data
)).
astype
(
'int64'
)
label
=
np
.
array
(
map
(
lambda
x
:
x
[
1
],
data
)).
astype
(
'int64'
)
label
=
label
.
reshape
([
-
1
,
1
])
label
=
label
.
reshape
([
-
1
,
1
])
loss
,
acc
,
weight
=
exe
.
run
(
loss
,
acc
,
weight
=
train_exe
.
run
(
fluid
.
default_main_program
(),
feed
=
{
'data'
:
image
,
feed
=
{
'data'
:
image
,
'label'
:
label
},
'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
iters
+=
1
num_samples
+=
len
(
label
)
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_losses
.
append
(
loss
)
train_accs
.
append
(
acc
)
train_accs
.
append
(
acc
)
print
(
"Pass: %d, Iter: %d, Loss: %f, Accuracy: %f"
%
print
(
"Pass: %d, Iter: %d, Loss: %f, Accuracy: %f"
%
...
...
benchmark/fluid/vgg.py
浏览文件 @
7792c63b
...
@@ -169,6 +169,7 @@ def main():
...
@@ -169,6 +169,7 @@ def main():
iters
,
num_samples
,
start_time
=
0
,
0
,
time
.
time
()
iters
,
num_samples
,
start_time
=
0
,
0
,
time
.
time
()
accuracy
=
fluid
.
average
.
WeightedAverage
()
accuracy
=
fluid
.
average
.
WeightedAverage
()
train_exe
=
fluid
.
ParallelExecutor
(
use_cuda
=
True
,
loss_name
=
avg_cost
.
name
)
for
pass_id
in
range
(
args
.
pass_num
):
for
pass_id
in
range
(
args
.
pass_num
):
accuracy
.
reset
()
accuracy
.
reset
()
train_accs
=
[]
train_accs
=
[]
...
@@ -184,14 +185,17 @@ def main():
...
@@ -184,14 +185,17 @@ def main():
y_data
=
np
.
array
(
map
(
lambda
x
:
x
[
1
],
data
)).
astype
(
"int64"
)
y_data
=
np
.
array
(
map
(
lambda
x
:
x
[
1
],
data
)).
astype
(
"int64"
)
y_data
=
y_data
.
reshape
([
-
1
,
1
])
y_data
=
y_data
.
reshape
([
-
1
,
1
])
loss
,
acc
,
weight
=
exe
.
run
(
loss
,
acc
,
weight
=
train_exe
.
run
(
fluid
.
default_main_program
(),
feed
=
{
"pixel"
:
img_data
,
feed
=
{
"pixel"
:
img_data
,
"label"
:
y_data
},
"label"
:
y_data
},
fetch_list
=
[
avg_cost
,
batch_acc
,
batch_size_tensor
])
fetch_list
=
[
accuracy
.
add
(
value
=
acc
,
weight
=
weight
)
avg_cost
.
name
,
batch_acc
.
name
,
batch_size_tensor
.
name
])
accuracy
.
add
(
value
=
np
.
array
(
np
.
mean
(
acc
)),
weight
=
np
.
mean
(
weight
))
iters
+=
1
iters
+=
1
num_samples
+=
len
(
y_data
)
num_samples
+=
len
(
y_data
)
loss
=
np
.
mean
(
np
.
array
(
loss
))
acc
=
np
.
mean
(
np
.
array
(
acc
))
print
(
print
(
"Pass = %d, Iter = %d, Loss = %f, Accuracy = %f"
%
"Pass = %d, Iter = %d, Loss = %f, Accuracy = %f"
%
(
pass_id
,
iters
,
loss
,
acc
)
(
pass_id
,
iters
,
loss
,
acc
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录