LSTM - Use deltaTime as a feature? How to handle irregular timestamps?

家住魔仙堡 提交于 2019-12-24 04:48:11

问题


I'm trying to create a LSTM for classification of data sequences.

The data structure of every training input that I would use is:

[[
[deltaX,deltaY,deltaTime],
[deltaX,deltaY,deltaTime],...
],class]

Where deltaX and deltaY reflect the change of X and Y in a given time deltaTime.
deltaTime is not the same everytime, it can vary from 40ms to 50ms to sometimes 1000ms. The 'class' at the end is a binary classification, that can be either 0 or 1.

Question 1 (regular LSTM): Should I include deltaTime as a feature input if I'll use a basic LSTM (Keras LSTM)?


I know that LSTMs have timestamps, but these are fixed to one given length. I have had a closer look at phasedLSTMs, but they seem to be more for 2 periodical timeframes which are shifted.


The only thing I encountered that could suit are Time-Aware LSTMs.

Question 2 (Time-Aware LSTM): Would you recommand them for my problem? If so: Is there a keras implementation, as I've not worked with tensorflow before.


回答1:


If I understand correctly deltaTime is an elapsed time interval between two sequential elements in your data set and deltas are different for different elements.

  1. In general LSTM would expect some regularity of duration between sequential elements. So to answer your first question: you probably should and since it is not real time series you can try other NN types as well. "Probably" because you will get the real answer when you check the precision on your test set with and without this feature.

  2. T-LSTM is a model (actually a code that modifies your training set and train reqular LSTM differently) that was proposed for the case exactly like yours. It hasn't been updated for two years and might require some modification to support TF2. Keras by itself is High End API and runs on top of multiple frameworks including TensorFlow. You can use it and run any TF functionality through it, although I would recommend using tf.keras

As a side note I would suggest for your problem to take a look on Time Delay Neural Networks. TDNN is implemented in TensorFlow, PyTorch and probably many other frameworks.




回答2:


given that your output is just a single binary variable, I'm not sure it's worth throwing that much technical machinery at the problem

a couple of alternatives:

  1. transform the data to a regularly sampled set of x,y coordinates. just pick a "good" set of times and interpolate the position changes appropriately (delta function would be easiest, or you could do linear, or something more specific to your problem). you can then use this engineered feature with a much larger variety of models, like a simple CNN

  2. a gaussian process regression would handle this sort of data directly, but is very different sort of model from a NN



来源:https://stackoverflow.com/questions/58436134/lstm-use-deltatime-as-a-feature-how-to-handle-irregular-timestamps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!