I want an LSTM to output one of two classes (Y, N), per frame, based on all the input so far.
My original inputs are very long (~100000 samples long, far more than a standard LSTM training can handle due to vanishing gradients).
- If the last seen instance out of the tokens (A, B) was A, output Y.
- If the last seen instance out of the tokens (A, B) was B, output N.
- The very long sequence is guaranteed to start with either A or B.
If the sequence was short, this would be quite easy.
For example, the following top lines and bottom lines correspond to inputs and required outputs:
ABCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
ACCCCCCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCACCCCCCCCCCCCCCCCACCCCCCCC
YYYYYYYYYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYYYYYYYYYYYYYYYYYYYY
Looks easy enough, just push batches comprised of chunks of the long sequence to the LSTM and have a coffee, right?
However, for my case, the available inputs are (A, B, C), of which (A, B) are extremely rare, meaning I can have batches comprised of 100% C's. The LSTM has no chance then, if not fed with some current state, telling it about the last A or B seen.
Unfortunately, this "state" is really something learned, and I can't just feed it as input AFAIK.
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
????????????????????????????????????????????????????????????????????
I am looking for a standard practice, or other references on how to train an LSTM or other RNN based model to be able to classify based on rare events far in history.
I hope this is clear, if not please ask and I will edit.
Please note that the data is labeled, and labeling can't be generated automatically for this task. The above is just an example for ease of understanding, the reality is more complicated.
last_seen = 'A'
. Unless there is some subtlety and some Cs are different from other Cs (in terms of whether or not A or B eventually happens), then forcing the problem to be "I must write an LSTM with very long memory" might be making a rod for your own back. It is hard to tell because you have simplified things, which is fine. However, i don't see that the Y/N switch is "composite" - the rules you state are simple and absolute, and there is no statement in any other direction. $\endgroup$