Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

selective_fc 和 fc的疑问

Open chenbblei opened this issue 8 years ago • 3 comments

根据文档中说 class paddle.v2.layer.selective_fc

select (paddle.v2.config_base.Layer) – The layer to select columns to output. It should be a sparse binary matrix, and is treated as the mask of selective fc. If it is not set or set to None, selective_fc acts exactly like fc.

但我在使用过程中 fc = paddle.layer.selective_fc( input=rnn_group_output, size=dict_size + 1, act=paddle.activation.Linear(), bias_attr=True, layer_attr=paddle.attr.ExtraLayerAttribute(drop_rate=0.5)) 这个之前是paddle.layer.fc改成 paddle.layer.selective_fc就报错了,上面说如果select不定义是完全和fc一致的啊,为什么会报错

报错信息如下: File "/data/anaconda2/lib/python2.7/site-packages/paddle/v2/config_base.py", line 52, in wrapped out = f(*args, **xargs) File "/data/anaconda2/lib/python2.7/site-packages/paddle/trainer_config_helpers/default_decorators.py", line 53, in wrapper return func(*args, **kwargs) File "/data/anaconda2/lib/python2.7/site-packages/paddle/trainer_config_helpers/default_decorators.py", line 53, in wrapper return func(*args, **kwargs) File "/data/anaconda2/lib/python2.7/site-packages/paddle/trainer_config_helpers/default_decorators.py", line 53, in wrapper return func(*args, **kwargs) File "/data/anaconda2/lib/python2.7/site-packages/paddle/trainer_config_helpers/default_decorators.py", line 53, in wrapper return func(*args, **kwargs) File "/data/anaconda2/lib/python2.7/site-packages/paddle/trainer_config_helpers/layers.py", line 415, in wrapper return method(*args, **kwargs) File "/data/anaconda2/lib/python2.7/site-packages/paddle/trainer_config_helpers/layers.py", line 5186, in selective_fc_layer assert isinstance(select, LayerOutput) AssertionError

chenbblei avatar May 10 '18 11:05 chenbblei

这里有一个isinstance的判断, 如果select 不为 LayerOutput的话就异常

seiriosPlus avatar May 10 '18 12:05 seiriosPlus

@seiriosPlus select 什么情况下会不为LayerOutput

chenbblei avatar May 10 '18 12:05 chenbblei

你这里相当于是填了none

seiriosPlus avatar May 10 '18 13:05 seiriosPlus