【Question】关于LSTM网络使用问题
Created by: LoganZhou
想使用LSTM网络来进行训练,参考trainer_config.lstm.py
文件对trainer_config.py
进行修改,但训练报错
I0225 17:12:06.709349 17327 Trainer.cpp:175] trainer mode: Normal
I0225 17:12:06.770145 17327 PyDataProvider2.cpp:243] loading dataprovider dataprovider::process
I0225 17:12:06.784571 17327 PyDataProvider2.cpp:243] loading dataprovider dataprovider::process
I0225 17:12:06.786155 17327 GradientMachine.cpp:135] Initing parameters..
I0225 17:12:06.796674 17327 GradientMachine.cpp:142] Init parameters done.
F0225 17:12:58.758431 17327 LstmLayer.cpp:155] Check failed: input.sequenceStartPositions
*** Check failure stack trace: ***
@ 0x93ca56 google::LogMessage::Fail()
@ 0x93c9a2 google::LogMessage::SendToLog()
@ 0x93c326 google::LogMessage::Flush()
@ 0x93f3c5 google::LogMessageFatal::~LogMessageFatal()
@ 0x640b87 paddle::LstmLayer::forward()
@ 0x6c9e60 paddle::NeuralNetwork::forward()
@ 0x6bc453 paddle::GradientMachine::forwardBackward()
@ 0x75786d paddle::TrainerInternal::forwardBackwardBatch()
@ 0x757dec paddle::TrainerInternal::trainOneBatch()
@ 0x752cf0 paddle::Trainer::trainOneDataBatch()
@ 0x7554ef paddle::Trainer::trainOnePass()
@ 0x756900 paddle::Trainer::train()
@ 0x5c6913 main
@ 0x2b87548e9d1d __libc_start_main
@ 0x5dcb41 (unknown)
/usr/local/Paddle-GPU/bin/paddle: line 109: 17327 Aborted (core dumped) ${DEBUGGER} $MYDIR/../opt/paddle/bin/paddle_trainer ${@:2}
LSTM构建部分如下:
output_label = []
link_encode = data_layer(name='link_encode', size=TERM_NUM)
for i in xrange(FORECASTING_NUM):
link_param = ParamAttr(
name='_link_vec.w', initial_max=1.0, initial_min=-1.0)
link_vec = fc_layer(input=link_encode, size=emb_size, param_attr=link_param)
lstm = simple_lstm(
input=link_vec, size=emb_size, lstm_cell_attr=ExtraAttr(drop_rate=0.25))
score = fc_layer(input=lstm, size=4, act=SoftmaxActivation())
if is_predict:
maxid = maxid_layer(score)
output_label.append(maxid)
else:
label = data_layer(name='label_%dmin' % ((i + 1) * 5), size=4)
cls = classification_cost(
input=score, name="cost_%dmin" % ((i + 1) * 5), label=label)
output_label.append(cls)
outputs(output_label)
之前也参考文档使用mixed_layer
来进行搭建LSTM,但也是报错
想知道这样构建错在哪里,望解答,谢谢!