Let's say we have A1, A2, ... , Am different articles in the corpus and each of them has W1, W2, ....., Ww words. We are training a language model on them. Do we:
Scheme 1
- Take the first batch of data as first S (Number of time steps) (S1, S2, .., Ss)words from each article (for the sake of simplicity let us assume batch size = m)
- Set the initial hidden state H0 = $[0,0,..,0]$
- Calculate loss and gradient on this batch and update the parameters
- Move a word forward and get next S words from each article (hence S2, S3, ... , Ss are the same words as in the previous batch)
- Use H1 calculated from previous step and use it as H0 in this iteration
- Do this to the end
*In this scheme we would have to use zero padding on the last batch (at the end of articles)
Scheme 2 Same as Scheme 1 but in step 5 we reinitialize H0 to a vector of Zeroes
Scheme 3 Same as scheme 1 but in step 4 we move s words forward to next non overlapping s words in each article and initialize H0 to Hs from last iteration
Scheme 4, 5, 6 Same as Scheme 1, 2, 3 but instead of taking s consecutive words we take first sentence from each article and zero pad them to the length S
What is the right way to go through the data in feeding it to a RNN, Please give reasons as well. I think it should be Scheme 1 but it could be really slow