diff --git a/python/paddle/v2/data_feeder.py b/python/paddle/v2/data_feeder.py index 63a8917c55a83dfdf59dece51b5025831501a7c1..56976baa3d523ec878a8470cfc280a4093f62ddf 100644 --- a/python/paddle/v2/data_feeder.py +++ b/python/paddle/v2/data_feeder.py @@ -35,15 +35,31 @@ class DataFeeder(DataProviderConverter): DataFeeder converts this mini-batch data entries into Arguments in order to feed it to C++ interface. - The example usage: + The simple usage shows below + + .. code-block:: python + + data_types = [('image', paddle.data_type.dense_vector(784)), + ('label', paddle.data_type.integer_value(10))] + feeding = ['image', 'label'] + feeder = DataFeeder(data_types=data_types, feeding=feeding) + + minibatch_data = [([1.0, 2.0, 3.0, ...], 5)] + + arg = feeder(minibatch_data) + + + If mini-batch data and data layers are not one to one mapping, we + could pass a dictionary to feeding parameter to represent the mapping + relationship. .. code-block:: python data_types = [('image', paddle.data_type.dense_vector(784)), ('label', paddle.data_type.integer_value(10))] - reader_dict = {'image':0, 'label':1} - feeder = DataFeeder(data_types=data_types, reader_dict=reader_dict) + feeding = {'image':0, 'label':1} + feeder = DataFeeder(data_types=data_types, feeding=feeding) minibatch_data = [ ( [1.0,2.0,3.0,4.0], 5, [6,7,8] ), # first sample ( [1.0,2.0,3.0,4.0], 5, [6,7,8] ) # second sample @@ -65,9 +81,9 @@ class DataFeeder(DataProviderConverter): a tuple of (data_name, data_type). :type data_types: list - :param reader_dict: A dictionary to specify the position of each data - in the input data. - :type feeding: dict + :param feeding: A dictionary or a sequence to specify the position of each + data in the input data. + :type feeding: dict|collections.Sequence|None """ def __init__(self, data_types, feeding=None):