New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question on WindowsDataset / TimeSeriesLoader #256
Comments
I've also noted that if I change the batch_size to 1 and use n_windows=32 I get what I assume is one window per time-series per epoch, i.e.
But I can only get either 1 or n_series batches per epoch - is it possible to sample many windows from multiple series on each epoch or is that not supported? |
Hi @david-waterworth , Anomaly detection as you mentioned is more of an interpolation task than an extrapolation task. Forecasting models tend to be a good baseline but I recommend you to use a dedicated model. In the team we have studied the anomaly detection task, we have this paper: The DGHL code is available with a link in the paper. We have not yet integrated in the repository. Hope this helps. |
Thanks @kdgutier, I understand the difference - I've implemented a number of timeseries VAE models. I'm just looking for a good general pytorch based framework I can use for deep timeseries models rather than write datasets / dataloaders myself. My question/confusion is that you don't appear to use all the windows in each epoch for training or for validation? The TimeSeriesLoader seems to sample a (potentially very small) subset of the windows from each series? This means that each epoch only trains the model on a very small subset of the data from what I can see - and then validates it on a subset of the validation data? Is this true? It seems that if all the series are the same length, and you set In my modelling I represent the data as a tensor (series,windows,features) and then I reshape to (series x windows,features) in order to ensure that the dataloader returns all the windows every time. |
Yes, the WindowsDataset is doing a 2 stage sampling strategy: first it samples a series, then it creates rolling windows and then samples the windows from it. Answering the questions @david-waterworth:
We are interested in extending NeuralForecast towards time series anomaly detection, we are interested in your past experience on the topic. |
Thanks, I'm interested in your first point "that breaks the gradient correlations" - can you expand on that - or point me to literature I can read? I don't ahve a lot of experience yet, I've implemented a few different VAE's. The most obvious thing you'd need to change is I don't see a way of implementing multivariate anomaly detection with the current design. Univariate could be fairly easily accomodated by using y_df, with x_df=None, but technically it should probably be the other way around. But in places you rely on having a y_df and that's univariate at the moment. |
The loss signals are correlated for windows of the same time series. It is almost an open research question to explore the relationship between SGD's variance and the algorithms generalization; but a general belief is that more variance in the gradients leads to better optima. Here is the "On Large batch training for deep learning" paper that won an award on the topic. This has not been carefully studied in the neural forecasting domain. |
Thanks yes that makes sense, and I've noticed that performance of a VAE is very poor if you train with strided windows where the stride length is the same length as the window size but as you imply if you have a stride of one then each window has near 100% correlation with the previous and next so there is a lot of redundancy/duplication. |
I'm keen to use
nueralforecast
for my own work. I'm interested in anomaly detection which is slightly different to forecasting - generally trying to reconstruct a window rather than forecasting the nextn
points but I think I can make it work.I'm a little confused around the
TimeSeriesLoader
though, I've been working through my own example but I'll refer to the getting started notebook to make it easier.The
WindowsDataset
is indexed by the number of unique_ids in the original dataset.So in this case there are 7 series, each containing 744 windows of length 144 i.e.
Where I'm really confused is the TimeSeriesLoader, I assumed when you set the batch_size=32 then I expect 7 * 774 // 32 batches of data per epoch, each having shape [32,144] but no matter what parameters I try, I only seem to get a single batch that's either of size batch_size or n_windows, i.e.
It only returns a single batch?
I'm expecting something like the following
Is there something wrong here, I want to train a model that has multiple long (1 year) series with 15T frequency and 1 day windows. I'm confused as to why the DataLoader only returns one batch per epoch?
The text was updated successfully, but these errors were encountered: