selective_fc 怎么使用
fc = paddle.layer.fc( input=rnn_group_output, size=dict_size + 1, act=paddle.activation.Linear(), bias_attr=True) 假设fc输出是5维,我想将1,2,5维和3,4,5,维分别取出来成为两个3维的输出结果,请问用selective_fc怎么实现
可以参考一下https://github.com/PaddlePaddle/Paddle/issues/1164
@seiriosPlus 这个链接还是全连接呀,只是他用了selective_fc,没有实现我上面要求的功能哦
@seiriosPlus 我这样写 fc_wav =paddle.layer.selective_fc(input=fc,select=sel_wav_binary,size=dict_size,act=paddle.activation.Tanh()) 其中sel_wav_binary=[0,0,0,1,1,1,1,1,1,1,1],结果报错了
fc_wav = paddle.layer.selective_fc(input=fc,select=sel_wav_binary,size=dict_size+1,act=paddle.activation.Tanh()) 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/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 5664, in warp_ctc_layer **ExtraLayerAttribute.to_kwargs(layer_attr)) File "/data/anaconda2/lib/python2.7/site-packages/paddle/trainer/config_parser.py", line 3943, in Layer return layer_func(name, **xargs) File "/data/anaconda2/lib/python2.7/site-packages/paddle/trainer/config_parser.py", line 3862, in init "Expecting the active_type of input layer to be linear or null") File "/data/anaconda2/lib/python2.7/site-packages/paddle/trainer/config_parser.py", line 161, in config_assert logger.fatal(msg) File "/data/anaconda2/lib/python2.7/site-packages/paddle/trainer/config_parser.py", line 4293, in my_fatal raise Exception() Exception
已经解决,换个act函数就可以了
@seiriosPlus fc_wav=paddle.layer.selective_fc(input=fc,select=sel_wav_binary,size=dict_size+1,act=paddle.activation.Linear()) # probability distribution with softmax # ctc cost ctc_loss_1 = paddle.layer.warp_ctc( input=fc_wav, label=text_data, size=dict_size + 1, blank=dict_size, norm_by_times=True)
报错如下:
F0510 19:10:41.672122 11590 SelectiveFullyConnectedLayer.cpp:134] Check failed: height == selCols_->getHeight() *** Check failure stack trace: *** @ 0x7fa932b942ed google::LogMessage::Fail() @ 0x7fa932b97d9c google::LogMessage::SendToLog() @ 0x7fa932b93e13 google::LogMessage::Flush() @ 0x7fa932b992ae google::LogMessageFatal::~LogMessageFatal() @ 0x7fa932894fec paddle::SelectiveFullyConnectedLayer::forward() @ 0x7fa93278ea4d paddle::NeuralNetwork::forward() @ 0x7fa93276bf54 paddle::TrainerThread::forward() @ 0x7fa93276d255 paddle::TrainerThread::computeThread() @ 0x7fa9a9e53870 (unknown) @ 0x7fa9bb8f8dc5 start_thread @ 0x7fa9baf1d21d __clone @ (nil) (unknown)
请问怎么解决
检查一下数据吧, 两个 height 不相等了
@seiriosPlus 哪两个height
其它地方以了解