keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.66k stars 19.42k forks source link

Can we train the Recurrent Neural Network with sequential targets? #120

Closed alzhusan closed 9 years ago

alzhusan commented 9 years ago

How to build a Recurrent Neural Network (RNN) to do some labeling task, such as semantic role-labeling?

The labeling task assigns a label to each element in the input sequence, therefore the training target is also a sequence. This type of task can be resolved by RNN.

I am a newbie of keras. I only found a RNN example for classification. Is there a way to train a RNN with sequential target?

fchollet commented 9 years ago

This is possible, you just have to use the return_sequences constructor argument of any recurrent unit (I suggested using GRU or LSTM as recurrent unit...).

With return_sequences = True, the output of the unit will be a sequence of vectors (each of size output_dim), one per element in the input sequence.

More here: http://keras.io/layers/recurrent/