Skip to content

Conversation

@reyoung
Copy link
Collaborator

@reyoung reyoung commented Apr 10, 2017

paddle.v2的feeding参数,原来只能接受一个map,key为data_layer的名字,value为reader里面的yield元素的index。

增加feeding可以传递一个list的情况。也就是直接按照reader里面的index传递data_layer的名字。不过这样不支持某一个元素传递两遍或者不使用的情况。

但是,增加这个功能,可以简化80%的使用场景。

@reyoung reyoung requested a review from qingqing01 April 10, 2017 11:19
Copy link
Contributor

@helinwang helinwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

input_types = []
if feeding is None:
feeding = default_feeding_map(data_types)
elif isinstance(feeding, collections.Sequence):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As here we allow feeding to be a new type -- Sequence, we should update/add the example in above comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有道理,我没注意到。这就加上。。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里我没太明白—— data_types。

reader返回的是Python native data types,比如tuple,而不是 paddle.data_type.XXX 对吧?所以我以为 paddle.data_type.XXX 应该是layer的属性,而不是DataFeeder的属性。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,这个data_type实际上是从layer拿过来的。这个类其实是paddle的一个内部类,不是用户的接口。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reyoung 沟通,这段example code并不是用户写的,而是我们的paddle/v2/trainer.py里的代码。其中

data_types = [('image', paddle.data_type.dense_vector(784)), ('label', paddle.data_type.integer_value(10))] 

实际上应该是

data_types = enumerate_data_types_of_data_layers(topology) 
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reyoung 沟通,这段example code并不是用户写的,而是我们的paddle/v2/trainer.py里的代码。其中

data_types = [('image', paddle.data_type.dense_vector(784)), ('label', paddle.data_type.integer_value(10))] 

实际上应该是

data_types = enumerate_data_types_of_data_layers(topology) 
@reyoung reyoung merged commit 892cc82 into PaddlePaddle:develop Apr 12, 2017
@reyoung reyoung deleted the feature/add_list_type_of_feeding branch April 25, 2017 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants