# How to train the same RNN over multiple series?

I have multiple separate time series and would like to train the same LSTM network on them. How to do in this situation? I can't just concatenate timeseries (along time), because I am afraid network will be confused by jumps at the points of concatenation.

How to overcome?

• Can you clarify a little bit more? Do these time series have the same length? what do you want the RNN to do eventually etc. May 30 '18 at 10:23
• All time series are of different lengths (coincidences are not excluded of course). The goal is to predict next one or more samples on the basis of previous ones.
– Dims
May 30 '18 at 11:20
• Is there a reason for the length variation?, can't resample them to make them have the same number of samples? May 30 '18 at 11:55
• @Amani they represent different periods of observations of some process; if I resample them, I will damage significant data
– Dims
May 30 '18 at 12:16
• LSTM is invariant to 'speed'. Meaning, its strength is detecting patterns whether or not they have the same length. I thing it's worth trying at least. May 30 '18 at 14:02

just re-use

model.fit()

on the fresh datasets using the already trained model, simple as that :) !

(given that you do it in Keras)

• What will it do at the beginning? Make previous sample zero?
– Dims
May 30 '18 at 12:17
• if it's part of the same code, the weights and the state will have the updated values, utilizing the learnt information from the previous training session. May 30 '18 at 12:22
• But won't it have the same effect as if I concatenated series?
– Dims
May 30 '18 at 12:58
• good idea, I guess it will have the similar "jump". Therefore consider model.reset_states() before feeding the new dataset and calling model.fit() :) May 30 '18 at 13:13

If I understand your question correctly, the reason you think cannot concatenate your time series into a one dataset is because of their different length. Depending on your problem, you can handle this issue in multiple manners in preprocessing. But the more common way is to use sequence padding. Preprocessing methods are natively implemented in keras: https://keras.io/preprocessing/sequence/.