Preparing captions for feeding into LSTMs
Now, before feeding word vectors along with image feature vectors, we need to perform a few more preprocessing steps on the caption data.
Before the preprocessing, let's look at a few basic statistics about the captions. A caption has approximately ten words on average, with a standard deviation of approximately two words. This information is important for us to truncate captions which are unnecessarily long.
First, following the preceding statistics, let's set the maximum caption length allowed to be 12.
Next, let's introduce two new word tokens, SOS and EOS. SOS denotes the start of a sentence, whereas EOS denotes the end of a sentence. These help the LSTM to identify both the start and end of a sentence easily.
Next, we will append captions with length less than 12 with EOS tokens such that their length is 12.
So, consider the following caption:
a man standing on a tennis court holding a racquet
This would appear as follows:
SOS a man standing on a...