|
|
|
@ -15,5 +15,46 @@
|
|
|
|
|
from py_paddle import DataProviderConverter
|
|
|
|
|
|
|
|
|
|
__all__ = ['DataFeeder']
|
|
|
|
|
"""
|
|
|
|
|
DataFeeder converts the data returned by paddle.reader into a data structure
|
|
|
|
|
of Arguments which is defined in the API. The paddle.reader usually returns
|
|
|
|
|
a list of mini-batch data. Each item in the list is a tuple or list, which is
|
|
|
|
|
one sample with multiple features. DataFeeder converts this mini-batch data
|
|
|
|
|
into Arguments in order to feed it to C++ interface.
|
|
|
|
|
|
|
|
|
|
The example usage:
|
|
|
|
|
|
|
|
|
|
data_types = [paddle.data_type.dense_vector(784),
|
|
|
|
|
paddle.data_type.integer_value(10)]
|
|
|
|
|
feeder = DataFeeder(input_types=data_types)
|
|
|
|
|
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
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# or
|
|
|
|
|
# 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
|
|
|
|
|
# ]
|
|
|
|
|
arg = feeder(minibatch_data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
input_types: A list of input data types. It's length is equal to the length
|
|
|
|
|
of data returned by paddle.reader. Each item specifies the type
|
|
|
|
|
of each feature.
|
|
|
|
|
mintbatch_data: A list of mini-batch data. Each item is a list or tuple,
|
|
|
|
|
for example:
|
|
|
|
|
[
|
|
|
|
|
(feature_0, feature_1, feature_2, ...), # first sample
|
|
|
|
|
(feature_0, feature_1, feature_2, ...), # second sample
|
|
|
|
|
...
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
An Arguments object contains this mini-batch data with multiple features.
|
|
|
|
|
The Arguments definition is in the API.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
DataFeeder = DataProviderConverter
|
|
|
|
|