Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a56dcf51
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
a56dcf51
编写于
6月 09, 2018
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix parallel_executor.py and xx_mnist.py
上级
3ff9ba0e
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
28 addition
and
20 deletion
+28
-20
python/paddle/dataset/flowers.py
python/paddle/dataset/flowers.py
+1
-1
python/paddle/fluid/data_feeder.py
python/paddle/fluid/data_feeder.py
+1
-1
python/paddle/fluid/parallel_executor.py
python/paddle/fluid/parallel_executor.py
+2
-5
python/paddle/fluid/tests/unittests/parallel_executor_test_base.py
...ddle/fluid/tests/unittests/parallel_executor_test_base.py
+3
-2
python/paddle/fluid/tests/unittests/test_parallel_executor_mnist.py
...dle/fluid/tests/unittests/test_parallel_executor_mnist.py
+20
-10
python/paddle/v2/dataset/flowers.py
python/paddle/v2/dataset/flowers.py
+1
-1
未找到文件。
python/paddle/dataset/flowers.py
浏览文件 @
a56dcf51
...
@@ -119,7 +119,7 @@ def reader_creator(data_file,
...
@@ -119,7 +119,7 @@ def reader_creator(data_file,
yield
sample
,
int
(
label
)
-
1
yield
sample
,
int
(
label
)
-
1
if
use_xmap
:
if
use_xmap
:
return
xmap_readers
(
mapper
,
reader
,
cpu_count
(
),
buffered_size
)
return
xmap_readers
(
mapper
,
reader
,
min
(
4
,
cpu_count
()
),
buffered_size
)
else
:
else
:
return
map_readers
(
mapper
,
reader
)
return
map_readers
(
mapper
,
reader
)
...
...
python/paddle/fluid/data_feeder.py
浏览文件 @
a56dcf51
...
@@ -150,7 +150,7 @@ class DataFeeder(object):
...
@@ -150,7 +150,7 @@ class DataFeeder(object):
elif
isinstance
(
self
.
place
,
core
.
CUDAPlace
):
elif
isinstance
(
self
.
place
,
core
.
CUDAPlace
):
return
core
.
get_cuda_device_count
()
return
core
.
get_cuda_device_count
()
else
:
else
:
return
m
ultiprocessing
.
cpu_count
(
)
return
m
in
(
4
,
multiprocessing
.
cpu_count
()
)
def
decorate_reader
(
self
,
def
decorate_reader
(
self
,
reader
,
reader
,
...
...
python/paddle/fluid/parallel_executor.py
浏览文件 @
a56dcf51
...
@@ -101,7 +101,7 @@ class ParallelExecutor(object):
...
@@ -101,7 +101,7 @@ class ParallelExecutor(object):
p
.
set_place
(
self
.
_act_places
[
-
1
])
p
.
set_place
(
self
.
_act_places
[
-
1
])
self
.
_places
.
append
(
p
)
self
.
_places
.
append
(
p
)
else
:
else
:
for
i
in
xrange
(
m
ultiprocessing
.
cpu_count
(
)):
for
i
in
xrange
(
m
in
(
4
,
multiprocessing
.
cpu_count
()
)):
p
=
core
.
Place
()
p
=
core
.
Place
()
self
.
_act_places
.
append
(
core
.
CPUPlace
())
self
.
_act_places
.
append
(
core
.
CPUPlace
())
p
.
set_place
(
self
.
_act_places
[
-
1
])
p
.
set_place
(
self
.
_act_places
[
-
1
])
...
@@ -110,10 +110,7 @@ class ParallelExecutor(object):
...
@@ -110,10 +110,7 @@ class ParallelExecutor(object):
if
exec_strategy
is
None
:
if
exec_strategy
is
None
:
exec_strategy
=
ExecutionStrategy
()
exec_strategy
=
ExecutionStrategy
()
if
use_cuda
:
exec_strategy
.
use_event
=
use_cuda
exec_strategy
.
use_event
=
True
else
:
exec_strategy
.
use_event
=
False
if
exec_strategy
.
num_threads
==
0
:
if
exec_strategy
.
num_threads
==
0
:
if
use_cuda
:
if
use_cuda
:
...
...
python/paddle/fluid/tests/unittests/parallel_executor_test_base.py
浏览文件 @
a56dcf51
...
@@ -23,6 +23,7 @@ __all__ = ['TestParallelExecutorBase']
...
@@ -23,6 +23,7 @@ __all__ = ['TestParallelExecutorBase']
class
TestParallelExecutorBase
(
unittest
.
TestCase
):
class
TestParallelExecutorBase
(
unittest
.
TestCase
):
def
check_network_convergence
(
self
,
def
check_network_convergence
(
self
,
method
,
method
,
use_cuda
=
True
,
memory_opt
=
True
,
memory_opt
=
True
,
iter
=
50
,
iter
=
50
,
batch_size
=
None
,
batch_size
=
None
,
...
@@ -53,7 +54,7 @@ class TestParallelExecutorBase(unittest.TestCase):
...
@@ -53,7 +54,7 @@ class TestParallelExecutorBase(unittest.TestCase):
adam
.
minimize
(
loss
)
adam
.
minimize
(
loss
)
if
memory_opt
:
if
memory_opt
:
fluid
.
memory_optimize
(
main
)
fluid
.
memory_optimize
(
main
)
place
=
fluid
.
CUDAPlace
(
0
)
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
startup_exe
=
fluid
.
Executor
(
place
)
startup_exe
=
fluid
.
Executor
(
place
)
startup_exe
.
run
(
startup
)
startup_exe
.
run
(
startup
)
exec_strategy
=
fluid
.
ExecutionStrategy
()
exec_strategy
=
fluid
.
ExecutionStrategy
()
...
@@ -64,7 +65,7 @@ class TestParallelExecutorBase(unittest.TestCase):
...
@@ -64,7 +65,7 @@ class TestParallelExecutorBase(unittest.TestCase):
if
use_parallel_executor
:
if
use_parallel_executor
:
exe
=
fluid
.
ParallelExecutor
(
exe
=
fluid
.
ParallelExecutor
(
True
,
use_cuda
,
loss_name
=
loss
.
name
,
loss_name
=
loss
.
name
,
exec_strategy
=
exec_strategy
,
exec_strategy
=
exec_strategy
,
build_strategy
=
build_strategy
)
build_strategy
=
build_strategy
)
...
...
python/paddle/fluid/tests/unittests/test_parallel_executor_mnist.py
浏览文件 @
a56dcf51
...
@@ -99,7 +99,9 @@ class TestMNIST(TestParallelExecutorBase):
...
@@ -99,7 +99,9 @@ class TestMNIST(TestParallelExecutorBase):
fluid
.
recordio_writer
.
convert_reader_to_recordio_file
(
fluid
.
recordio_writer
.
convert_reader_to_recordio_file
(
MNIST_RECORDIO_FILE
,
reader
,
feeder
)
MNIST_RECORDIO_FILE
,
reader
,
feeder
)
def
check_simple_fc_convergence
(
self
,
balance_parameter_opt_between_cards
):
def
check_simple_fc_convergence
(
self
,
balance_parameter_opt_between_cards
,
use_cuda
=
True
):
self
.
check_network_convergence
(
simple_fc_net
)
self
.
check_network_convergence
(
simple_fc_net
)
self
.
check_network_convergence
(
simple_fc_net
,
allow_op_delay
=
True
)
self
.
check_network_convergence
(
simple_fc_net
,
allow_op_delay
=
True
)
...
@@ -109,17 +111,19 @@ class TestMNIST(TestParallelExecutorBase):
...
@@ -109,17 +111,19 @@ class TestMNIST(TestParallelExecutorBase):
simple_fc_net
,
simple_fc_net
,
feed_dict
=
{
"image"
:
img
,
feed_dict
=
{
"image"
:
img
,
"label"
:
label
},
"label"
:
label
},
use_cuda
=
use_cuda
,
balance_parameter_opt_between_cards
=
balance_parameter_opt_between_cards
balance_parameter_opt_between_cards
=
balance_parameter_opt_between_cards
)
)
def
test_simple_fc
(
self
):
def
test_simple_fc
(
self
):
self
.
check_simple_fc_convergence
(
False
)
self
.
check_simple_fc_convergence
(
False
,
use_cuda
=
True
)
def
test_simple_fc_with_new_strategy
(
self
):
def
test_simple_fc_with_new_strategy
(
self
):
self
.
check_simple_fc_convergence
(
True
)
self
.
check_simple_fc_convergence
(
True
,
use_cuda
=
True
)
def
check_simple_fc_parallel_accuracy
(
self
,
def
check_simple_fc_parallel_accuracy
(
self
,
balance_parameter_opt_between_cards
):
balance_parameter_opt_between_cards
,
use_cuda
=
True
):
img
=
np
.
zeros
(
shape
=
[
32
,
784
],
dtype
=
'float32'
)
img
=
np
.
zeros
(
shape
=
[
32
,
784
],
dtype
=
'float32'
)
label
=
np
.
ones
(
shape
=
[
32
,
1
],
dtype
=
'int64'
)
label
=
np
.
ones
(
shape
=
[
32
,
1
],
dtype
=
'int64'
)
single_first_loss
,
single_last_loss
=
self
.
check_network_convergence
(
single_first_loss
,
single_last_loss
=
self
.
check_network_convergence
(
...
@@ -127,6 +131,7 @@ class TestMNIST(TestParallelExecutorBase):
...
@@ -127,6 +131,7 @@ class TestMNIST(TestParallelExecutorBase):
seed
=
1000
,
seed
=
1000
,
feed_dict
=
{
"image"
:
img
,
feed_dict
=
{
"image"
:
img
,
"label"
:
label
},
"label"
:
label
},
use_cuda
=
use_cuda
,
use_parallel_executor
=
False
)
use_parallel_executor
=
False
)
parallel_first_loss
,
parallel_last_loss
=
self
.
check_network_convergence
(
parallel_first_loss
,
parallel_last_loss
=
self
.
check_network_convergence
(
method
=
simple_fc_net
,
method
=
simple_fc_net
,
...
@@ -143,13 +148,15 @@ class TestMNIST(TestParallelExecutorBase):
...
@@ -143,13 +148,15 @@ class TestMNIST(TestParallelExecutorBase):
self
.
assertAlmostEquals
(
p_l
,
single_last_loss
[
0
],
delta
=
1e-6
)
self
.
assertAlmostEquals
(
p_l
,
single_last_loss
[
0
],
delta
=
1e-6
)
def
test_simple_fc_parallel_accuracy
(
self
):
def
test_simple_fc_parallel_accuracy
(
self
):
self
.
check_simple_fc_parallel_accuracy
(
False
)
self
.
check_simple_fc_parallel_accuracy
(
False
,
use_cuda
=
True
)
self
.
check_simple_fc_parallel_accuracy
(
False
,
use_cuda
=
False
)
def
test_simple_fc_parallel_accuracy_with_new_strategy
(
self
):
def
test_simple_fc_parallel_accuracy_with_new_strategy
(
self
):
self
.
check_simple_fc_parallel_accuracy
(
True
)
self
.
check_simple_fc_parallel_accuracy
(
True
,
use_cuda
=
True
)
self
.
check_simple_fc_parallel_accuracy
(
True
,
use_cuda
=
False
)
def
check_batchnorm_fc_convergence
(
self
,
def
check_batchnorm_fc_convergence
(
balance_parameter_opt_between_cards
):
self
,
balance_parameter_opt_between_cards
,
use_cuda
):
self
.
check_network_convergence
(
fc_with_batchnorm
)
self
.
check_network_convergence
(
fc_with_batchnorm
)
img
=
np
.
zeros
(
shape
=
[
32
,
784
],
dtype
=
'float32'
)
img
=
np
.
zeros
(
shape
=
[
32
,
784
],
dtype
=
'float32'
)
label
=
np
.
ones
(
shape
=
[
32
,
1
],
dtype
=
'int64'
)
label
=
np
.
ones
(
shape
=
[
32
,
1
],
dtype
=
'int64'
)
...
@@ -157,14 +164,17 @@ class TestMNIST(TestParallelExecutorBase):
...
@@ -157,14 +164,17 @@ class TestMNIST(TestParallelExecutorBase):
fc_with_batchnorm
,
fc_with_batchnorm
,
feed_dict
=
{
"image"
:
img
,
feed_dict
=
{
"image"
:
img
,
"label"
:
label
},
"label"
:
label
},
use_cuda
=
use_cuda
,
balance_parameter_opt_between_cards
=
balance_parameter_opt_between_cards
balance_parameter_opt_between_cards
=
balance_parameter_opt_between_cards
)
)
def
test_batchnorm_fc
(
self
):
def
test_batchnorm_fc
(
self
):
self
.
check_batchnorm_fc_convergence
(
False
)
self
.
check_batchnorm_fc_convergence
(
False
,
use_cuda
=
True
)
self
.
check_batchnorm_fc_convergence
(
False
,
use_cuda
=
False
)
def
test_batchnorm_fc_with_new_strategy
(
self
):
def
test_batchnorm_fc_with_new_strategy
(
self
):
self
.
check_batchnorm_fc_convergence
(
True
)
self
.
check_batchnorm_fc_convergence
(
True
,
use_cuda
=
True
)
self
.
check_batchnorm_fc_convergence
(
True
,
use_cuda
=
False
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
python/paddle/v2/dataset/flowers.py
浏览文件 @
a56dcf51
...
@@ -119,7 +119,7 @@ def reader_creator(data_file,
...
@@ -119,7 +119,7 @@ def reader_creator(data_file,
yield
sample
,
int
(
label
)
-
1
yield
sample
,
int
(
label
)
-
1
if
use_xmap
:
if
use_xmap
:
return
xmap_readers
(
mapper
,
reader
,
cpu_count
(
),
buffered_size
)
return
xmap_readers
(
mapper
,
reader
,
min
(
4
,
cpu_count
()
),
buffered_size
)
else
:
else
:
return
map_readers
(
mapper
,
reader
)
return
map_readers
(
mapper
,
reader
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录