Skip to content

Commit 333cd3d

Browse files
committed
Add comments about feeding a list to feeder.
1 parent cac5ad6 commit 333cd3d

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

python/paddle/v2/data_feeder.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,31 @@ class DataFeeder(DataProviderConverter):
3535
DataFeeder converts this mini-batch data entries into Arguments in order
3636
to feed it to C++ interface.
3737
38-
The example usage:
38+
The simple usage shows below
39+
40+
.. code-block:: python
41+
42+
data_types = [('image', paddle.data_type.dense_vector(784)),
43+
('label', paddle.data_type.integer_value(10))]
44+
feeding = ['image', 'label']
45+
feeder = DataFeeder(data_types=data_types, feeding=feeding)
46+
47+
minibatch_data = [([1.0, 2.0, 3.0, ...], 5)]
48+
49+
arg = feeder(minibatch_data)
50+
51+
52+
If mini-batch data and data layers are not one to one mapping, we
53+
could pass a dictionary to feeding parameter to represent the mapping
54+
relationship.
3955
4056
4157
.. code-block:: python
4258
4359
data_types = [('image', paddle.data_type.dense_vector(784)),
4460
('label', paddle.data_type.integer_value(10))]
45-
reader_dict = {'image':0, 'label':1}
46-
feeder = DataFeeder(data_types=data_types, reader_dict=reader_dict)
61+
feeding = {'image':0, 'label':1}
62+
feeder = DataFeeder(data_types=data_types, feeding=feeding)
4763
minibatch_data = [
4864
( [1.0,2.0,3.0,4.0], 5, [6,7,8] ), # first sample
4965
( [1.0,2.0,3.0,4.0], 5, [6,7,8] ) # second sample
@@ -65,9 +81,9 @@ class DataFeeder(DataProviderConverter):
6581
a tuple of (data_name, data_type).
6682
6783
:type data_types: list
68-
:param reader_dict: A dictionary to specify the position of each data
69-
in the input data.
70-
:type feeding: dict
84+
:param feeding: A dictionary or a sequence to specify the position of each
85+
data in the input data.
86+
:type feeding: dict|collections.Sequence|None
7187
"""
7288

7389
def __init__(self, data_types, feeding=None):

0 commit comments

Comments
 (0)