I had a question about using LSTMs for processing data over time. That is, how can I feed data one-by-one into an LSTM, without the LSTM forgetting about my previous inputs?
I had looked through the Keras "stateful" argument a bit, but it had only made me more confused. I'm not sure whether it's relevant or not for my purposes.
E.g.
Say I am sequentially/chronologically getting data from a soil sensor. The first sample of data is s1. s1 is composed of multiple values (e.g. sunlight, soil temperature, soil humidity). I will get another sample of data, s2, in a few seconds, but I only have s1 right now. So I input s1 into the LSTM as the first timestep. When s2 comes along, I then propagate it through the LSTM as the second timestep. Is this possible to do in Keras?
CodePudding user response:
RNNs or LSTMs made to remember what happend in past, though, without stateful=True
the state is set to 0 for every batch. So, the stateful flag is made for LSTMs to "remeber what happened" in previous batches, with stateful=True
LSTM passes its state from previous batch to the next one, so the information doesn't vanish.
https://fairyonice.github.io/Stateful-LSTM-model-training-in-Keras.html heres a good acticle for you about the statful
flag.