2
$\begingroup$

I just read paper about cnn + rnn for text recognition. The labels of dataset is tensor of char index (e.g [0, 1, 2 ] for image with label "abc"). Since the label of each input has different length do I need to convert the label to sparse tensor value ? since the paper does not mention about it.

$\endgroup$
0
$\begingroup$

My assumption here is that if the input vectors are of variable length, you should use something like keras.preprocessing.sequence.pad_sequences (as well as a masking layer to ignore these padded values) as a means of reformatting all input samples to the same size so that the input to your recurrent model meets the requirement of having a fixed num_timesteps length.
Function Documentation:

Pads sequences to the same length.

This function transforms a list of num_samples sequences (lists of integers) into a 2D Numpy array of shape (num_samples, num_timesteps). num_timesteps is either the maxlen argument if provided, or the length of the longest sequence otherwise.

Sequences that are shorter than num_timesteps are padded with value at the end.

Sequences longer than num_timesteps are truncated so that they fit the desired length. The position where padding or truncation happens is determined by the arguments padding and truncating, respectively.

$\endgroup$
0

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.