Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
吃玉米的猫
Paddle
提交
3a09693f
P
Paddle
项目概览
吃玉米的猫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3a09693f
编写于
3月 18, 2019
作者:
S
sneaxiy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change API name
test=develop
上级
161b8ddc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
36 addition
and
16 deletion
+36
-16
paddle/fluid/API.spec
paddle/fluid/API.spec
+4
-4
python/paddle/fluid/compiler.py
python/paddle/fluid/compiler.py
+3
-1
python/paddle/fluid/layers/io.py
python/paddle/fluid/layers/io.py
+3
-0
python/paddle/fluid/reader.py
python/paddle/fluid/reader.py
+8
-8
python/paddle/fluid/tests/unittests/test_decoupled_py_reader.py
.../paddle/fluid/tests/unittests/test_decoupled_py_reader.py
+17
-2
python/paddle/fluid/tests/unittests/test_py_reader_sample_generator.py
.../fluid/tests/unittests/test_py_reader_sample_generator.py
+1
-1
未找到文件。
paddle/fluid/API.spec
浏览文件 @
3a09693f
...
...
@@ -61,10 +61,10 @@ paddle.fluid.io.load_params (ArgSpec(args=['executor', 'dirname', 'main_program'
paddle.fluid.io.load_persistables (ArgSpec(args=['executor', 'dirname', 'main_program', 'filename'], varargs=None, keywords=None, defaults=(None, None)), ('document', '28df5bfe26ca7a077f91156abb0fe6d2'))
paddle.fluid.io.save_inference_model (ArgSpec(args=['dirname', 'feeded_var_names', 'target_vars', 'executor', 'main_program', 'model_filename', 'params_filename', 'export_for_deployment'], varargs=None, keywords=None, defaults=(None, None, None, True)), ('document', '582d87b8df75a5a639a107db8ff86f9c'))
paddle.fluid.io.load_inference_model (ArgSpec(args=['dirname', 'executor', 'model_filename', 'params_filename', 'pserver_endpoints'], varargs=None, keywords=None, defaults=(None, None, None)), ('document', '7a5255386075dac3c75b7058254fcdcb'))
paddle.fluid.io.PyReader.__init__ (ArgSpec(args=['self', 'feed_list', 'capacity', 'use_double_buffer', 'iterable'], varargs=None, keywords=None, defaults=(True, False)), ('document', '
18211b287474b401bc460d3f73dbc1c7
'))
paddle.fluid.io.PyReader.decorate_
paddle_reader (ArgSpec(args=['self', 'reader', 'places'], varargs=None, keywords=None, defaults=(None,)), ('document', 'faef298f73e91aedcfaf5d184f3109b7
'))
paddle.fluid.io.PyReader.decorate_sample_generator (ArgSpec(args=['self', 'sample_generator', 'batch_size', 'drop_last', 'places'], varargs=None, keywords=None, defaults=(True, None)), ('document', '
d3fe49fc342e7778ed086e965f41bf1
2'))
paddle.fluid.io.PyReader.decorate_
tensor_provider (ArgSpec(args=['self', 'reader', 'places'], varargs=None, keywords=None, defaults=(None,)), ('document', 'd10224fef1095247063b6976da793021
'))
paddle.fluid.io.PyReader.__init__ (ArgSpec(args=['self', 'feed_list', 'capacity', 'use_double_buffer', 'iterable'], varargs=None, keywords=None, defaults=(True, False)), ('document', '
b3d72958b2568aae3f90f72abdcb7d1a
'))
paddle.fluid.io.PyReader.decorate_
batch_generator (ArgSpec(args=['self', 'reader', 'places'], varargs=None, keywords=None, defaults=(None,)), ('document', 'd10224fef1095247063b6976da793021
'))
paddle.fluid.io.PyReader.decorate_sample_generator (ArgSpec(args=['self', 'sample_generator', 'batch_size', 'drop_last', 'places'], varargs=None, keywords=None, defaults=(True, None)), ('document', '
7abd9cf7d695bab5bb6cf7ded5903cb
2'))
paddle.fluid.io.PyReader.decorate_
sample_list_generator (ArgSpec(args=['self', 'reader', 'places'], varargs=None, keywords=None, defaults=(None,)), ('document', 'faef298f73e91aedcfaf5d184f3109b7
'))
paddle.fluid.io.PyReader.reset (ArgSpec(args=['self'], varargs=None, keywords=None, defaults=None), ('document', 'ff1cc1e2beb8824d453656c72c28ddfb'))
paddle.fluid.io.PyReader.start (ArgSpec(args=['self'], varargs=None, keywords=None, defaults=None), ('document', 'b7ea0a548991924e4cfe61a577b8e56d'))
paddle.fluid.initializer.ConstantInitializer.__init__ (ArgSpec(args=['self', 'value', 'force_cpu'], varargs=None, keywords=None, defaults=(0.0, False)), ('document', '6adf97f83acf6453d4a6a4b1070f3754'))
...
...
python/paddle/fluid/compiler.py
浏览文件 @
3a09693f
...
...
@@ -127,7 +127,9 @@ class CompiledProgram(object):
program in the given places. Otherwise, the places used when compiled
is determined by the Executor, and the places used are controlled
by environment variables: FLAGS_selected_gpus or CUDA_VISIBLE_DEVICES
if using GPU; or CPU_NUM if using CPU.
if using GPU; or CPU_NUM if using CPU. For example, if you want to
run on GPU 0 and 1, set places=[fluid.CUDAPlace(0), fluid.CUDAPlace(1)].
If you want to run on 2 CPU cores, set places=[fluid.CPUPlace()]*2.
Returns:
self
...
...
python/paddle/fluid/layers/io.py
浏览文件 @
3a09693f
...
...
@@ -632,6 +632,9 @@ def _py_reader(capacity,
reader
.
reset
=
__reset__
reader
.
decorate_tensor_provider
=
__set_tensor_provider__
reader
.
decorate_paddle_reader
=
__set_paddle_reader__
reader
.
decorate_batch_generator
=
__set_tensor_provider__
reader
.
decorate_sample_list_generator
=
__set_paddle_reader__
reader
.
start
=
__start__
return
reader
...
...
python/paddle/fluid/reader.py
浏览文件 @
3a09693f
...
...
@@ -82,7 +82,7 @@ class PyReader(object):
reader = fluid.io.PyReader(feed_list=[image, label],
capacity=4, iterable=False)
reader.decorate_
paddle_reade
r(user_defined_reader)
reader.decorate_
sample_list_generato
r(user_defined_reader)
... # definition of network is omitted
executor.run(fluid.default_main_program())
for _ in range(EPOCH_NUM):
...
...
@@ -109,7 +109,7 @@ class PyReader(object):
reader = fluid.io.PyReader(feed_list=[image, label],
capacity=4, iterable=True)
reader.decorate_
paddle_reade
r(user_defined_reader,
reader.decorate_
sample_list_generato
r(user_defined_reader,
places=fluid.cuda_places())
... # definition of network is omitted
executor.run(fluid.default_main_program())
...
...
@@ -287,7 +287,7 @@ class PyReader(object):
:code:`places` must be set when the PyReader object is iterable.
If all inputs have no lods, this method is faster than
:code:`decorate_
paddle_reade
r(paddle.batch(sample_generator, ...))` .
:code:`decorate_
sample_list_generato
r(paddle.batch(sample_generator, ...))` .
Args:
sample_generator (generator): Python generator that yields
...
...
@@ -306,7 +306,7 @@ class PyReader(object):
break
if
has_lod
:
self
.
decorate_
paddle_reade
r
(
self
.
decorate_
sample_list_generato
r
(
paddle
.
batch
(
sample_generator
,
batch_size
=
batch_size
,
...
...
@@ -319,9 +319,9 @@ class PyReader(object):
batch_size
=
batch_size
,
generator
=
sample_generator
,
drop_last
=
drop_last
)
self
.
decorate_
tensor_provide
r
(
reader
,
places
=
places
)
self
.
decorate_
batch_generato
r
(
reader
,
places
=
places
)
def
decorate_
paddle_reade
r
(
self
,
reader
,
places
=
None
):
def
decorate_
sample_list_generato
r
(
self
,
reader
,
places
=
None
):
'''
Set the data source of the PyReader object.
...
...
@@ -347,9 +347,9 @@ class PyReader(object):
for
slots
in
paddle_reader
():
yield
[
slots
[
var
.
name
]
for
var
in
self
.
_feed_list
]
self
.
decorate_
tensor_provide
r
(
__tensor_reader_impl__
,
places
)
self
.
decorate_
batch_generato
r
(
__tensor_reader_impl__
,
places
)
def
decorate_
tensor_provide
r
(
self
,
reader
,
places
=
None
):
def
decorate_
batch_generato
r
(
self
,
reader
,
places
=
None
):
'''
Set the data source of the PyReader object.
...
...
python/paddle/fluid/tests/unittests/test_decoupled_py_reader.py
浏览文件 @
3a09693f
...
...
@@ -25,6 +25,7 @@ CLASS_NUM = 10
def
random_reader
():
np
.
random
.
seed
(
1
)
for
i
in
range
(
BATCH_SIZE
*
40
):
image
=
np
.
random
.
random
([
784
])
label
=
np
.
random
.
random_integers
(
low
=
0
,
high
=
CLASS_NUM
-
1
)
...
...
@@ -79,7 +80,8 @@ class TestBase(unittest.TestCase):
reader
=
paddle
.
batch
(
random_reader
,
batch_size
=
BATCH_SIZE
)
ps
=
places
if
use_double_buffer
else
fluid
.
cpu_places
(
len
(
places
))
py_reader
.
decorate_paddle_reader
(
py_reader
.
decorate_sample_list_generator
(
reader
,
places
=
ps
if
py_reader
.
iterable
else
None
)
exe
=
fluid
.
Executor
(
place
=
places
[
0
])
...
...
@@ -92,6 +94,7 @@ class TestBase(unittest.TestCase):
step
=
0
step_list
=
[]
loss_list
=
[]
start_t
=
time
.
time
()
if
not
py_reader
.
iterable
:
for
_
in
six
.
moves
.
range
(
EPOCH_NUM
):
...
...
@@ -102,6 +105,7 @@ class TestBase(unittest.TestCase):
L
,
=
exe
.
run
(
program
=
prog
,
fetch_list
=
[
loss
],
use_program_cache
=
True
)
loss_list
.
append
(
np
.
mean
(
L
))
step
+=
1
except
fluid
.
core
.
EOFException
:
py_reader
.
reset
()
...
...
@@ -123,10 +127,15 @@ class TestBase(unittest.TestCase):
feed
=
d
,
fetch_list
=
[
loss
],
use_program_cache
=
True
)
loss_list
.
append
(
np
.
mean
(
L
))
step
+=
1
step_list
.
append
(
step
)
end_t
=
time
.
time
()
ret
=
{
"time"
:
end_t
-
start_t
,
"step"
:
step_list
}
ret
=
{
"time"
:
end_t
-
start_t
,
"step"
:
step_list
,
"loss"
:
np
.
array
(
loss_list
)
}
return
ret
def
prepare_places
(
self
,
with_data_parallel
,
with_cpu
=
True
,
with_gpu
=
True
):
...
...
@@ -148,12 +157,18 @@ class TestBase(unittest.TestCase):
for
with_data_parallel
in
[
True
,
False
]:
for
p
in
self
.
prepare_places
(
with_data_parallel
):
for
use_double_buffer
in
[
False
,
True
]:
results
=
[]
for
use_legacy_py_reader
in
[
False
,
True
]:
ret
=
self
.
run_main
(
use_legacy_py_reader
=
use_legacy_py_reader
,
with_data_parallel
=
with_data_parallel
,
places
=
p
,
use_double_buffer
=
use_double_buffer
)
results
.
append
(
ret
)
if
not
use_double_buffer
:
diff
=
np
.
max
(
np
.
abs
(
results
[
0
][
'loss'
]
-
results
[
1
][
'loss'
]))
self
.
assertLess
(
diff
,
1e-3
)
if
__name__
==
'__main__'
:
...
...
python/paddle/fluid/tests/unittests/test_py_reader_sample_generator.py
浏览文件 @
3a09693f
...
...
@@ -62,7 +62,7 @@ class TestCaseBase(unittest.TestCase):
all_datas
=
self
.
generate_all_data
(
batch_reader
)
if
not
use_sample_generator
:
py_reader
.
decorate_
paddle_reade
r
(
py_reader
.
decorate_
sample_list_generato
r
(
batch_reader
,
places
=
fluid
.
cpu_places
())
else
:
py_reader
.
decorate_sample_generator
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录