From dc02bfdf2fb9eb904cda2b3bb493fb25c7393ab1 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Mon, 10 Apr 2017 19:16:03 +0800 Subject: [PATCH] Add list type of feeding --- python/paddle/v2/data_feeder.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/paddle/v2/data_feeder.py b/python/paddle/v2/data_feeder.py index bda8e22fd2..63a8917c55 100644 --- a/python/paddle/v2/data_feeder.py +++ b/python/paddle/v2/data_feeder.py @@ -13,7 +13,7 @@ # limitations under the License. from py_paddle import DataProviderConverter - +import collections import paddle.trainer.PyDataProvider2 as pydp2 __all__ = ['DataFeeder'] @@ -75,6 +75,13 @@ class DataFeeder(DataProviderConverter): input_types = [] if feeding is None: feeding = default_feeding_map(data_types) + elif isinstance(feeding, collections.Sequence): + feed_list = feeding + feeding = dict() + for i, name in enumerate(feed_list): + feeding[name] = i + elif not isinstance(feeding, dict): + raise TypeError("Feeding should be dict or sequence or None.") self.feeding = feeding for each in data_types: -- GitLab