From c5292b181ee441c842c8f9ea4db24ed0130324cc Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Fri, 28 Sep 2018 17:17:40 +0800 Subject: [PATCH] change py_reader_by_data to create_py_reader_by_data --- paddle/fluid/API.spec | 2 +- python/paddle/fluid/layers/io.py | 12 +++++++----- .../tests/unittests/test_py_reader_using_executor.py | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/paddle/fluid/API.spec b/paddle/fluid/API.spec index 9b04a58c985..7a8f2a185f7 100644 --- a/paddle/fluid/API.spec +++ b/paddle/fluid/API.spec @@ -168,7 +168,7 @@ paddle.fluid.layers.batch ArgSpec(args=['reader', 'batch_size'], varargs=None, k paddle.fluid.layers.double_buffer ArgSpec(args=['reader', 'place', 'name'], varargs=None, keywords=None, defaults=(None, None)) paddle.fluid.layers.random_data_generator ArgSpec(args=['low', 'high', 'shapes', 'lod_levels', 'for_parallel'], varargs=None, keywords=None, defaults=(True,)) paddle.fluid.layers.py_reader ArgSpec(args=['capacity', 'shapes', 'dtypes', 'lod_levels', 'name', 'use_double_buffer'], varargs=None, keywords=None, defaults=(None, None, True)) -paddle.fluid.layers.py_reader_by_data ArgSpec(args=['capacity', 'feed_list', 'name', 'use_double_buffer'], varargs=None, keywords=None, defaults=(None, True)) +paddle.fluid.layers.create_py_reader_by_data ArgSpec(args=['capacity', 'feed_list', 'name', 'use_double_buffer'], varargs=None, keywords=None, defaults=(None, True)) paddle.fluid.layers.Preprocessor.__init__ ArgSpec(args=['self', 'reader', 'name'], varargs=None, keywords=None, defaults=(None,)) paddle.fluid.layers.Preprocessor.block ArgSpec(args=[], varargs='args', keywords='kwds', defaults=None) paddle.fluid.layers.Preprocessor.inputs ArgSpec(args=['self'], varargs=None, keywords=None, defaults=None) diff --git a/python/paddle/fluid/layers/io.py b/python/paddle/fluid/layers/io.py index 09bff06d3e7..e0e397f6393 100644 --- a/python/paddle/fluid/layers/io.py +++ b/python/paddle/fluid/layers/io.py @@ -30,8 +30,8 @@ from ..unique_name import generate as unique_name __all__ = [ 'data', 'open_files', 'read_file', 'shuffle', 'batch', 'double_buffer', - 'random_data_generator', 'py_reader', 'py_reader_by_data', 'Preprocessor', - 'load' + 'random_data_generator', 'py_reader', 'create_py_reader_by_data', + 'Preprocessor', 'load' ] @@ -480,7 +480,7 @@ def _py_reader(capacity, feed_list=None): if feed_list is not None: - if isinstance(feed_list, list): + if not isinstance(feed_list, list): raise TypeError("feed_list should be a list of Variable" " instead of " + str(type(feed_list))) lod_levels = [] @@ -758,7 +758,10 @@ def py_reader(capacity, use_double_buffer=use_double_buffer) -def py_reader_by_data(capacity, feed_list, name=None, use_double_buffer=True): +def create_py_reader_by_data(capacity, + feed_list, + name=None, + use_double_buffer=True): """ Create a Python reader for data feeding in Python @@ -781,7 +784,6 @@ def py_reader_by_data(capacity, feed_list, name=None, use_double_buffer=True): 1. The basic usage of :code:`py_reader` is as follows: - >>> import paddle.v2 >>> import paddle.fluid as fluid >>> import paddle.dataset.mnist as mnist >>> diff --git a/python/paddle/fluid/tests/unittests/test_py_reader_using_executor.py b/python/paddle/fluid/tests/unittests/test_py_reader_using_executor.py index aaa6e762d6e..b85b94c939f 100644 --- a/python/paddle/fluid/tests/unittests/test_py_reader_using_executor.py +++ b/python/paddle/fluid/tests/unittests/test_py_reader_using_executor.py @@ -58,7 +58,7 @@ def simple_fc_net(in_size, if use_feed_list: data = fluid.layers.data(name="data", dtype='float32', shape=[in_size]) label = fluid.layers.data(name='label', dtype='int64', shape=[1]) - reader = fluid.layers.py_reader_by_data( + reader = fluid.layers.create_py_reader_by_data( capacity=queue_capacity, use_double_buffer=False, feed_list=[data, label]) @@ -114,7 +114,8 @@ class TestPyReaderUsingExecutor(unittest.TestCase): print({ 'use_cuda': use_cuda, 'use_parallel_executor': use_parallel_executor, - 'use_double_buffer': use_double_buffer + 'use_double_buffer': use_double_buffer, + 'use_feed_list': use_feed_list }) self.main(use_cuda, use_parallel_executor, use_double_buffer, use_feed_list) -- GitLab