How to use cross-batch statefulness with functional API in TensorFlow?

Viewed 72

I have a TensorFlow functional API model with different inputs to perform classification. One of my inputs is a sequence of game events with +- 20,000 timesteps that goes into an LSTM layer. I also have around 5000 samples, so the training memory required is very big. I read on the Tensorflow documentation that I could use cross-batch statefulness for very long sequences. But I don't really know how to transform the example in the link to work with the functional API.

My input data for the sequences are of the form: (#samples, #timesteps, 1).

I guess I need to transform it to: 
- (#samples, #timesteps0-500, 1)
- (#samples, #timesteps501-1000, 1)
- ...

But how could I then use this split data as an input? Is there perhaps a way to let the LSTM layer split longer sequences automatically to improve processing?

0 Answers
Related