1
$\begingroup$

I'd like to use RNN for binary classification. One example of such task is sentiment analysis, where embedding of words from a sample are fed into network one by one. But all implementations I have found do define maximal length of a sample and crop or pad samples to this length.

Why is this necessary? I thought the very purpose of RNN was to deal with variable length samples, because if we know sample length beforehand, simple convolutional network can deal with it. There will be more weights, but they will be easier to train.

$\endgroup$
1
$\begingroup$

The answer is that you need to "unfold" the recurrent neural network (https://shapeofdata.wordpress.com/2016/04/27/rolling-and-unrolling-rnns/)

The easiest way is to build an "unfolded" model of a fixed length and train it. After you found the weights - when you need to use your model to label the sequences, you will not have any limit on the length.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.