Git Product home page Git Product logo

autoformer's Introduction

Autoformer (NeurIPS 2021)

Autoformer: Decomposition Transformers with Auto-Correlation for Long-Term Series Forecasting

Time series forecasting is a critical demand for real applications. Enlighted by the classic time series analysis and stochastic process theory, we propose the Autoformer as a general series forecasting model [paper]. Autoformer goes beyond the Transformer family and achieves the series-wise connection for the first time.

In long-term forecasting, Autoformer achieves SOTA, with a 38% relative improvement on six benchmarks, covering five practical applications: energy, traffic, economics, weather and disease.

🚩News (2023.08) Autoformer has been included in Hugging Face. See blog.

🚩News (2023.06) The extension version of Autoformer (Interpretable weather forecasting for worldwide stations with a unified deep model) has been published in Nature Machine Intelligence as the Cover Article.

🚩News (2023.02) Autoformer has been included in our [Time-Series-Library], which covers long- and short-term forecasting, imputation, anomaly detection, and classification.

🚩News (2022.02-2022.03) Autoformer has been deployed in 2022 Winter Olympics to provide weather forecasting for competition venues, including wind speed and temperature.

Autoformer vs. Transformers

1. Deep decomposition architecture

We renovate the Transformer as a deep decomposition architecture, which can progressively decompose the trend and seasonal components during the forecasting process.



Figure 1. Overall architecture of Autoformer.

2. Series-wise Auto-Correlation mechanism

Inspired by the stochastic process theory, we design the Auto-Correlation mechanism, which can discover period-based dependencies and aggregate the information at the series level. This empowers the model with inherent log-linear complexity. This series-wise connection contrasts clearly from the previous self-attention family.



Figure 2. Auto-Correlation mechansim.

Get Started

  1. Install Python 3.6, PyTorch 1.9.0.
  2. Download data. You can obtain all the six benchmarks from Google Drive. All the datasets are well pre-processed and can be used easily.
  3. Train the model. We provide the experiment scripts of all benchmarks under the folder ./scripts. You can reproduce the experiment results by:
bash ./scripts/ETT_script/Autoformer_ETTm1.sh
bash ./scripts/ECL_script/Autoformer.sh
bash ./scripts/Exchange_script/Autoformer.sh
bash ./scripts/Traffic_script/Autoformer.sh
bash ./scripts/Weather_script/Autoformer.sh
bash ./scripts/ILI_script/Autoformer.sh
  1. Special-designed implementation
  • Speedup Auto-Correlation: We built the Auto-Correlation mechanism as a batch-normalization-style block to make it more memory-access friendly. See the paper for details.

  • Without the position embedding: Since the series-wise connection will inherently keep the sequential information, Autoformer does not need the position embedding, which is different from Transformers.

Reproduce with Docker

To easily reproduce the results using Docker, conda and Make, you can follow the next steps:

  1. Initialize the docker image using: make init.
  2. Download the datasets using: make get_dataset.
  3. Run each script in scripts/ using make run_module module="bash scripts/ETT_script/Autoformer_ETTm1.sh" for each script.
  4. Alternatively, run all the scripts at once:
for file in `ls scripts`; do make run_module module="bash scripts/$script"; done

A Simple Example

See predict.ipynb for workflow (in Chinese).

Main Results

We experiment on six benchmarks, covering five main-stream applications. We compare our model with ten baselines, including Informer, N-BEATS, etc. Generally, for the long-term forecasting setting, Autoformer achieves SOTA, with a 38% relative improvement over previous baselines.

Baselines

We will keep adding series forecasting models to expand this repo:

  • Autoformer
  • Informer
  • Transformer
  • Reformer
  • LogTrans
  • N-BEATS

Citation

If you find this repo useful, please cite our paper.

@inproceedings{wu2021autoformer,
  title={Autoformer: Decomposition Transformers with {Auto-Correlation} for Long-Term Series Forecasting},
  author={Haixu Wu and Jiehui Xu and Jianmin Wang and Mingsheng Long},
  booktitle={Advances in Neural Information Processing Systems},
  year={2021}
}

Contact

If you have any questions or want to use the code, please contact [email protected].

Acknowledgement

We appreciate the following github repos a lot for their valuable code base or datasets:

https://github.com/zhouhaoyi/Informer2020

https://github.com/zhouhaoyi/ETDataset

https://github.com/laiguokun/multivariate-time-series-data

autoformer's People

Contributors

azulgarza avatar chucktg avatar danilogalisteu avatar dg1609 avatar elisim avatar erikalien5595 avatar gukgurgel avatar shaido987 avatar wuhaixu2016 avatar yilabs avatar zero-coder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autoformer's Issues

Explaining code details

First,thank you very much for this splendid work.
This paper is full of insights and concrete work

Somehow,When I see code part like calculating auto-correlation it's a little bit confusing,have you considered to make a markdown.file to explain some details,if it's convenient for you to do this,thank you very much

change d_layers and e_layers number

I used Autoformer model in my project with double amount of e_layers and d_layers but model didn't work properly (returns nan output) specially on CPU
e_layers = 4
d_layers = 2
While debugging the model, I understood that, nan outputs came from nn.LayerNorm in my_Layernorm class and also the second DecoderLayer in Decoder layers list

Exchange rate dataset length

Hello, thanks for making your code public!

In your paper you say that the exchange rate dataset ranges from 1990 to 2016, however after downloading it using the link in the README.md there is only data from 1990 to 2010. This gives the series a length of 7588. After splitting with a ratio of 7:1:2, as given in the paper, the validation set has a length of just 759 which causes problems when trying to evaluate a forecast length of 720 and a history of 96. Is there data missing from the dataset?

关于调整样本滑块间隔的问题

作者,你好,目前在学习用autoformer做时序数据预测,谢谢你的论文和源码,受益良多。
有个问题想请教下,烦请解答下。
数据集使用ETTm1.csv,目前data_loader的__getitem__函数中,s_begin = index,即样本数据是通过传入的index进行滑块。在该数据集上也就是15分钟一个间隔往后滑一个间隔。因为业务场景需要(以天为单位进行预测),我原本设想通过调整代码s_begin = index * 96,来严格限定每个样本数据从一天中的第一个时刻开始,一个batch包含32天的样本。但是运行代码时报以下错误:
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 530, in __next__data = self._next_data()
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1204, in _next_data
return self._process_data(data)
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1250, in _process_data
data.reraise()
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/_utils.py", line 457, in reraise
raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 8.
Original Traceback (most recent call last):
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 52, in fetch
return self.collate_fn(data)
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 172, in default_collate
return [default_collate(samples) for samples in transposed] # Backwards compatibility.
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 172, in
return [default_collate(samples) for samples in transposed] # Backwards compatibility.
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 146, in default_collate
return default_collate([torch.as_tensor(b) for b in batch])
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/utils/collate.py", line 137, in default_collate
out = elem.new(storage).resize
(len(batch), *list(elem.size()))
RuntimeError: Trying to resize storage that is not resizable
尝试调整drop_last和num_workers,无效。

请教一下作者,复现Autoformer在exchange_rate数据集上的结果不理想

您好!
最近有幸看到了您的Autoformer的顶会论文,下载了您在github上的源码进行实验。我用的是exchange_rate.csv数据集进行测试,测试环境的是window10+anconda+python3.6+pytorch1.9,使用了您的/scripts/Exchange_script/Autoformer.sh脚本中的第二个命令行:
python -u run.py --is_training 1 --root_path ./dataset/exchange_rate/ --data_path exchange_rate.csv --model_id Exchange_96_192 --model Autoformer --data custom --features M --seq_len 96 --label_len 48 --pred_len 192 --e_layers 2 --d_layers 1 --factor 3 --enc_in 8 --dec_in 8 --c_out 8 --des 'Exp' --itr 1 --train_epochs 1
得到的命令行窗口输出如下:
Use GPU: cuda:0

start training : Exchange_96_192_Autoformer_custom_ftM_sl96_ll48_pl192_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_'Exp'0>>>>>>>>>>>>>>>>>>>>>>>>>>
train 5024
val 569
test 1326
iters: 100, epoch: 1 | loss: 0.3912162
speed: 0.8711s/iter; left time: 50.5228s
Epoch: 1 cost time: 110.04935765266418
Epoch: 1, Steps: 157 | Train Loss: 0.3484863 Vali Loss: 0.3024623 Test Loss: 0.2717947
Validation loss decreased (inf --> 0.302462). Saving model ...
Updating learning rate to 0.0001
testing : Exchange_96_192_Autoformer_custom_ftM_sl96_ll48_pl192_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue
'Exp'_0<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test 1326
test shape: (41, 32, 192, 8) (41, 32, 192, 8)
test shape: (1312, 192, 8) (1312, 192, 8)
mse:0.27179470658302307, mae:0.3820776641368866

 但是在输出的可视化图形上看到预测值和实际值有不小的差距,无法复现论文中附录E.2的图Figure 12。
 我将您的源码中的exp_main.py中的test函数中可视化部分做了小小的修改,让他输出全部图形:

#if i % 20 == 0: #全部打印
input = batch_x.detach().cpu().numpy()
gt = np.concatenate((input[0, :, -1], true[0, :, -1]), axis=0)
pd = np.concatenate((input[0, :, -1], pred[0, :, -1]), axis=0)
visual(gt, pd, os.path.join(folder_path, str(i) + '.pdf'))
但是从图形上看真实值和预测值相差很大,例如:

结果

我想请教一下您,这个结果是因为我设置不对,还是理解有问题,还望您百忙之中能够给予一点指教,谢谢您了!!
完整的可视化图形输出如下:
result.pdf

little details debug

run.py Line 57
parser.add_argument('--output_attention', action='store_true', help='whether to output attention in ecoder')
Does the handsome Author want to say "whether to output attention in encoder,instead of 'ecoder'?"

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

Hello!

I used Autoformer on CPU before and it worked fine, but now I'm trying to use with GPU: cuda:0, but I got the following error:

Args in experiment: Namespace(activation='gelu', batch_size=32, bucket_size=4, c_out=1, checkpoints='./checkpoints/', d_ff=2048, d_layers=1, d_model=2048, data='custom', data_path='ts_85afd5ce-bd63-445a-9ec5-23941e3c9421.csv', dec_in=1, des='Exp', devices='0,1,2,3', distil=True, do_predict=False, dropout=0.05, e_layers=2, embed='timeF', enc_in=1, factor=3, features='S', freq='t', gpu=0, is_training=1, itr=1, label_len=90, learning_rate=0.0001, loss='mse', lradj='type1', model='Autoformer', model_id='ts_180', moving_avg=25, n_hashes=4, n_heads=8, num_workers=10, output_attention=False, patience=3, pred_len=90, root_path='./dataset/ts/', seq_len=180, target='OT', train_epochs=2, use_amp=False, use_gpu=True, use_multi_gpu=False)
Use GPU: cuda:0
start training : ts_180_Autoformer_custom_ftS_sl180_ll90_pl90_dm2048_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0
train 3945
val 514
test 1115
iters: 100, epoch: 1 | loss: 0.3764235
speed: 0.4895s/iter; left time: 71.9599s
Epoch: 1 cost time: 60.09772181510925
Traceback (most recent call last):
File "/work/run.py", line 120, in
exp.train(setting)
File "/work/exp/exp_main.py", line 176, in train
vali_loss = self.vali(vali_data, vali_loader, criterion)
File "/work/exp/exp_main.py", line 77, in vali
outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/work/models/Autoformer.py", line 88, in forward
enc_out, attns = self.encoder(enc_out, attn_mask=enc_self_mask)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/work/layers/Autoformer_EncDec.py", line 103, in forward
x, attn = attn_layer(x, attn_mask=attn_mask)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/work/layers/Autoformer_EncDec.py", line 69, in forward
new_x, attn = self.attention(
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/work/layers/AutoCorrelation.py", line 156, in forward
out, attn = self.inner_correlation(
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/work/layers/AutoCorrelation.py", line 124, in forward
V = self.time_delay_agg_inference(values.permute(0, 2, 3, 1).contiguous(), corr).permute(0, 3, 1, 2)
File "/work/layers/AutoCorrelation.py", line 72, in time_delay_agg_inference
tmp_delay = init_index + delay[:, i].unsqueeze(1).unsqueeze(1).unsqueeze(1).repeat(1, head, channel, length)
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

Thank you very much for any help!

LogTrans update time

Hi, I look forward to your work very much! I want to know when you shared the code about Logtrans. Thank you very much for your sharing!

Problem in reproducing results with `--features MS`

Hi! I have read your paper and tried to reproduce the results for the ETT datasets.

When trying to configure --features MS - which means that I want to predict univariate target using multivariate input, I see that the model's output still contains all the features ([bs x ts x 7] for ETTh1 for example).

I tried to fix it by changing --c_out to 1 instead of 7, but in the model, the trends vector is not fixed properly:

dec_out = trend_part + seasonal_part

So here, seasonal_part has a dimension of [bs x ts x 1] and trend_part has a dimension of [bs x ts x 7] (no error thrown because PyTorch allow this action to occur).

What is your implementation?

Thank you

Scripts for univariate experiments in paper

Hi! Thanks for the well documented repository! I'm trying to replicate the univariate experiments in as in the paper, could you kindly upload the script files for them as well? Thanks!

Problem in reproducing results in ETT dataset

Hi Haixu, I really like the idea in your paper, but I've encountered some problem when I tried to reproduce the results for ETTh1 dataset.

I've used the latest version of your code, and got the following results which are quite weird

pred_len 24: mse:0.4061545729637146, mae:0.4404798150062561
pred_len 48: mse:0.48272132873535156, mae:0.46404534578323364
pred_len 168: mse:0.49321380257606506, mae:0.48073211312294006
pred_len 336: mse:0.5146851539611816, mae:0.4921443462371826
pred_len 720: mse:0.49855655431747437, mae:0.5004686117172241

Environment : linux, [email protected], python3.8, cuda10.2, cudnn7.6.5_0.

Also, why the ETTh1 performance of informer in your paper is different from that in the original paper of informer? The MSE for pred_len 720 is up to 3.379, whereas in the original paper of informer, the MSE is 1.215.
I've attached the result log and the script I used (adapted to slurm system).
Best regards
log and script.zip

ILI (illness dataset) length

Thanks for making your code public!

The ILI dataset has a length of 966. In the paper it's stated that a split ratio of 7:1:2 is used, which would give train, val and test lengths of 676:97:193. How were you able to evaluate horizon lengths of 96,192,336,720 with a test set length of only 193?

Hi I have some questions about ./scripts

你好!
我在Traffic数据集上进行Autoformer和Informer 的Multivariate预测的时候,运行 ./scripts/Traffic_script/Autoformer.sh 得到的结果和论文中的结果接近,但是运行./scripts/Traffic_script/Informer.sh的时候有报错RuntimeError: Given groups=1, weight of size [512, 1, 3], expected input[32, 862, 98] to have 1 channels, but got 862 channels instead。个人认为是脚本中的参数:--enc_in 1 --dec_in 1 --c_out 1 有问题。对于Multivariate的预测,参数应该设置为--enc_in 862 --dec_in 862 --c_out 862

User accessibility

Thank you for adding this amazing state-of-the-art model to python.

I wanted to ask if it could be possible to make the files easy to run directly from python, without requiring bash or Docker.

Label Len 的参数问题

您的数据和标签大概是如下这样的

x
-----------------

xmark        
-----------------

label                    
---------

y                          
--------------------------

ymark                  
--------------------------

将数据送入网络后会丢弃label, 替换为pred_len
我不知道使用label的意义是什么,它会影响到什么吗?

How to fine-tune hyperparameters

Hello!

I'm using Autoformer on my custom dataset, but it seems like an overfitting.
image

I used default parameters, but it looks like it's not a good idea. Which parameters should I fine-tune, and is there any simple method to do it?

Thank you very much in advance.

Questions about irregular time-series data

Autoformer is an amazing work, and i studied much from your paper and your code.
I have a dataset, irregular, the periodicity of my dataset is not obvious compared to datasets you choosen in your paper, such as ETT.
I run Autoformer in my dataset, the qualitative results seem ok, but the qualitative (visualization) results are not good. Like the issue #35.
Therefore, do you have any suggestions about the irregular time-series dataset without obvious periodicity ?

Training time

CPU: Intel i9-10900K (20) @ 5.300GHz
GPU: NVIDIA NVIDIA Corporation Devic 3090 24GB
Above is my device config.
The training time is way too long,would you please tell me the concrete time you're using in training auto-former model.

关于预测的小疑问

给定一组数据,预测7天,Autoformer的输出是什么呢?(1)它是一次性把7天的数据都给预测出来呢?(2)还是类似于Lstm的单步预测一样,先预测第一天的值,紧接着再把第一天的值也归进数据里再进行预测第二天的值呢?

Train, Val, Test dataset leakage

Hi, thanks for making your code public! It's great for the forecasting community and research.

I am unsure about how you create your train, val and test splits. The splits seem to be overlapping with a length of self.seq_len, see the code snippets below.

border1s = [0, num_train - self.seq_len, len(df_raw) - num_test - self.seq_len]
border2s = [num_train, num_train + num_vali, len(df_raw)]
border1 = border1s[self.set_type]
border2 = border2s[self.set_type]

self.data_x = data[border1:border2]
self.data_y = data[border1:border2]

If self.seq_len is longer than self.pred_len then sequences that the model is trained on will be present in the validation split. Data used for validation would also be present in the test split.

Results for univariate experiments

Hello, could you provide the setting for univariate prediction? The results I run are a bit different from the results reported in the paper. I run the code according to the default setting.

python run.py --is_training 1 --root_path ./data/ --data_path ETTm2.csv --model_id ETTm2_96_96 --model Autoformer --data ETTm2 --features S --seq_len 96 --label_len 48 --pred_len 96 --e_layers 2 --d_layers 1 --factor 3 --enc_in 1 --dec_in 1 --c_out 1 --des 'Exp' --itr 1
mse:0.1019936352968216, mae:0.2465277761220932
But the results in the paper are: mse:0.065, mae:0.189

python run.py --is_training 1 --root_path ./data/ --data_path ETTm2.csv --model_id ETTm2_96_336 --model Autoformer --data ETTm2 --features S --seq_len 96 --label_len 48 --pred_len 336 --e_layers 2 --d_layers 1 --factor 3 --enc_in 1 --dec_in 1 --c_out 1 --des 'Exp' --itr 1
mse:0.18364596366882324, mae:0.3304046392440796
But the results in the paper are: mse:0.154, mae:0.305

Choose proper moving average kernel for short input

Hello! Thank you for your well-commented code! I'm currently using Autoformer to deal with some data which have very short input length, such as only 8 timestamps. I noticed that the default moving average kernel size in series decomposition part is 25, which maybe too long for the input in this case. I tried some smaller kernel such as 3, 5, 7. But the model turned out to be worse on validation dataset. Do you have any suggestions about adjusting hyper parameters for short input? Any suggestion would be appreciated. Thank you!

What does 'OT' mean?

I saw the OT column name in every dataset, but I don't know what is it.
B24E02B6-15EB-42e1-8B87-74E3577A391C

Could you please explain it?

About the truncation of values and keys in AutoCorrelation

Hello, I am very curious about the truncation in AutoCorrelation for cross attention. Why the values are truncated by the first L elements but not the last L, which might be more correlated to the outputs.

https://github.com/thuml/Autoformer/blob/main/layers/AutoCorrelation.py#L111

 def forward(self, queries, keys, values, attn_mask):
        B, L, H, E = queries.shape
        _, S, _, D = values.shape
        if L > S:
            zeros = torch.zeros_like(queries[:, :(L - S), :]).float()
            values = torch.cat([values, zeros], dim=1)
            keys = torch.cat([keys, zeros], dim=1)
        else:
            values = values[:, :L, :, :]
            keys = keys[:, :L, :, :]

为什么训练测试都使用同一个__getitem__方法

作者您好,我想具体问一下您,您这个模型在训练测试的时候都使用的同一个__getitem__方法,而且dataloader加载数据调用__getitem__方法,是每次滑动一个单位进行获取数据。那么有个问题:这会导致前面预测的数据,再一次被预测,最后输出结果不就是有很多重复的预测吗?想请问下您这样设置目的是什么哩

关于调整样本滑块间隔的问题

作者,你好,目前在学习用autoformer做时序数据预测,谢谢你的论文和源码,受益良多。
有个问题想请教下,烦请解答下。
数据集使用ETTm1.csv,目前data_loader的__getitem__函数中,s_begin = index,即样本数据是通过传入的index进行滑块。在该数据集上也就是15分钟一个间隔往后滑一个间隔。因为业务场景需要(以天为单位进行预测),我原本设想通过调整代码s_begin = index * 96,来严格限定每个样本数据从一天中的第一个时刻开始,一个batch包含32天的样本。但是运行代码时报以下错误:
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 530, in __next__data = self._next_data()
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1204, in _next_data
return self._process_data(data)
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1250, in _process_data
data.reraise()
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/_utils.py", line 457, in reraise
raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 8.
Original Traceback (most recent call last):
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 52, in fetch
return self.collate_fn(data)
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 172, in default_collate
return [default_collate(samples) for samples in transposed] # Backwards compatibility.
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 172, in
return [default_collate(samples) for samples in transposed] # Backwards compatibility.
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 146, in default_collate
return default_collate([torch.as_tensor(b) for b in batch])
File "/home/ubuntu/anaconda3/envs/series-forecasting/lib/python3.8/site-packages/torch/utils/data/utils/collate.py", line 137, in default_collate
out = elem.new(storage).resize
(len(batch), *list(elem.size()))
RuntimeError: Trying to resize storage that is not resizable
尝试调整drop_last和num_workers,无效。

Training Problem

start training : ETTm1_96_672_Autoformer_ETTm1_ftM_sl96_ll48_pl672_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0>>>>>>>>>>>>>>>>>>>>>>>>>>
train 33793
val 10849
test 10849
iters: 100, epoch: 1 | loss: 0.5350901
speed: 4.5272s/iter; left time: 47358.7275s
iters: 200, epoch: 1 | loss: 0.4332319
speed: 4.5712s/iter; left time: 47362.3486s
iters: 300, epoch: 1 | loss: 0.4808801
speed: 4.5620s/iter; left time: 46810.8673s
iters: 400, epoch: 1 | loss: 0.5168055
speed: 4.5696s/iter; left time: 46431.6680s
iters: 500, epoch: 1 | loss: 0.4912913
speed: 4.5852s/iter; left time: 46131.6203s
iters: 600, epoch: 1 | loss: 0.4775451
speed: 4.5742s/iter; left time: 45564.0464s
iters: 700, epoch: 1 | loss: 0.5060694
speed: 4.5875s/iter; left time: 45237.1464s
iters: 800, epoch: 1 | loss: 0.5316107
speed: 4.5767s/iter; left time: 44673.6112s
iters: 900, epoch: 1 | loss: 0.4948809
speed: 4.5745s/iter; left time: 44194.6974s
iters: 1000, epoch: 1 | loss: 0.4570811
speed: 4.5657s/iter; left time: 43652.2512s
Epoch: 1 cost time: 4828.672526597977
Traceback (most recent call last):
File "/home/fight/Desktop/Autoformer/Autoformer-main/run.py", line 116, in
exp.train(setting)
File "/home/fight/Desktop/Autoformer/Autoformer-main/exp/exp_main.py", line 173, in train
vali_loss = self.vali(vali_data, vali_loader, criterion)
File "/home/fight/Desktop/Autoformer/Autoformer-main/exp/exp_main.py", line 76, in vali
outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)
File "/home/fight/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/fight/Desktop/Autoformer/Autoformer-main/models/Autoformer.py", line 90, in forward
enc_out, attns = self.encoder(enc_out, attn_mask=enc_self_mask)
File "/home/fight/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/fight/Desktop/Autoformer/Autoformer-main/layers/Autoformer_EncDec.py", line 103, in forward
x, attn = attn_layer(x, attn_mask=attn_mask)
File "/home/fight/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/fight/Desktop/Autoformer/Autoformer-main/layers/Autoformer_EncDec.py", line 69, in forward
new_x, attn = self.attention(
File "/home/fight/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/fight/Desktop/Autoformer/Autoformer-main/layers/AutoCorrelation.py", line 167, in forward
out, attn = self.inner_correlation(
File "/home/fight/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/fight/Desktop/Autoformer/Autoformer-main/layers/AutoCorrelation.py", line 135, in forward
V = self.time_delay_agg_inference(values.permute(0, 2, 3, 1).contiguous(), corr).permute(0, 3, 1, 2)
File "/home/fight/Desktop/Autoformer/Autoformer-main/layers/AutoCorrelation.py", line 66, in time_delay_agg_inference
init_index = torch.arange(length).unsqueeze(0).unsqueeze(0).unsqueeze(0).repeat(batch, head, channel, 1).cuda()
File "/home/fight/anaconda3/lib/python3.9/site-packages/torch/cuda/init.py", line 216, in _lazy_init
torch._C._cuda_init()
RuntimeError: No CUDA GPUs are available

Hello,author Wu,have you met situation like this?Would you like to give some advice to this question?
This is my configuration

  -+ssssssssssssssssssyyssss+-         OS: Ubuntu 18.04.6 LTS x86_64 
.ossssssssssssssssssdMMMNysssso.       Host: 90Q90022CP ZHENGJIUZHE REN9000 

/ssssssssssshdmmNNmmyNMMMMhssssss/ Kernel: 5.4.0-109-generic
+ssssssssshmydMMMMMMMNddddyssssssss+ Uptime: 22 days, 8 hours, 7 mins
/sssssssshNMMMyhhyyyyhmNMMMNhssssssss/ Packages: 1986
.ssssssssdMMMNhsssssssssshNMMMdssssssss. Shell: bash 4.4.20
+sssshhhyNMMNyssssssssssssyNMMMysssssss+ Resolution: 1920x1080
ossyNMMMNyMMhsssssssssssssshmmmhssssssso DE: GNOME 3.28.4
ossyNMMMNyMMhsssssssssssssshmmmhssssssso WM: GNOME Shell
+sssshhhyNMMNyssssssssssssyNMMMysssssss+ WM Theme: Adwaita
.ssssssssdMMMNhsssssssssshNMMMdssssssss. Theme: Ambiance [GTK2/3]
/sssssssshNMMMyhhyyyyhdNMMMNhssssssss/ Icons: Ubuntu-mono-dark [GTK2/3]
+sssssssssdmydMMMMMMMMddddyssssssss+ Terminal: gnome-terminal
/ssssssssssshdmNNNNmyNMMMMhssssss/ CPU: Intel i9-10900K (20) @ 5.300GHz
.ossssssssssssssssssdMMMNysssso. GPU: NVIDIA NVIDIA Corporation Devic
-+sssssssssssssssssyyyssss+- Memory: 21480MiB / 64125MiB

关于使用自己的数据集

作者你好!非常感谢您的这篇论文给我带来了启发与灵感,在使用我自己的数据集的时候我遇到了一些问题,希望您能百忙之中抽空为我解答一下。

这是我的数据集:
AL_WIND_07_12.csv

这是运行结果:Args in experiment:
Namespace(activation='gelu', batch_size=32, bucket_size=4, c_out=6, checkpoints='./checkpoints/', d_ff=2048, d_layers=1, d_model=512, data='windresult(2)', data_path='windresult(2).csv', dec_in=6, des='exp', devices='0,1,2,3', distil=True, do_predict=False, dropout=0.05, e_layers=2, embed='timeF', enc_in=6, factor=3, features='M', freq='t', gpu=0, is_training=1, itr=1, label_len=48, learning_rate=1e-05, loss='mse', lradj='type1', model='Autoformer', model_id='windresult(2)_96_168', moving_avg=25, n_hashes=4, n_heads=8, num_workers=10, output_attention=False, patience=3, pred_len=168, root_path='./data', seq_len=96, target='OT', train_epochs=10, use_amp=False, use_gpu=True, use_multi_gpu=False)
Use GPU: cuda:0

start training : windresult(2)_96_168_Autoformer_windresult(2)_ftM_sl96_ll48_pl168_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_exp_0>>>>>>>>>>>>>>>>>>>>>>>>>>
train 48860
val 6851
test 13868
iters: 100, epoch: 1 | loss: 1.3873028
speed: 0.2157s/iter; left time: 3270.9135s
iters: 200, epoch: 1 | loss: 5.2782578
speed: 0.1973s/iter; left time: 2971.3670s
iters: 300, epoch: 1 | loss: 0.8285253
speed: 0.1991s/iter; left time: 2978.6951s
iters: 400, epoch: 1 | loss: 0.6783259
speed: 0.2014s/iter; left time: 2993.2308s
iters: 500, epoch: 1 | loss: 0.5328820
speed: 0.2033s/iter; left time: 3001.2006s
iters: 600, epoch: 1 | loss: 0.4745004
speed: 0.2032s/iter; left time: 2978.4878s
iters: 700, epoch: 1 | loss: 0.6617956
speed: 0.2042s/iter; left time: 2973.3634s
iters: 800, epoch: 1 | loss: 0.8940198
speed: 0.2053s/iter; left time: 2969.4257s
iters: 900, epoch: 1 | loss: 0.4608745
speed: 0.2061s/iter; left time: 2959.5262s
iters: 1000, epoch: 1 | loss: 0.6747336
speed: 0.2064s/iter; left time: 2942.9809s
iters: 1100, epoch: 1 | loss: 1.0136081
speed: 0.2069s/iter; left time: 2929.6766s
iters: 1200, epoch: 1 | loss: 0.5815385
speed: 0.2067s/iter; left time: 2906.8596s
iters: 1300, epoch: 1 | loss: 0.7630769
speed: 0.2069s/iter; left time: 2889.0642s
iters: 1400, epoch: 1 | loss: 0.9147382
speed: 0.2073s/iter; left time: 2872.9977s
iters: 1500, epoch: 1 | loss: 0.5026098
speed: 0.2068s/iter; left time: 2845.5929s
Epoch: 1 cost time: 313.20935106277466
Epoch: 1, Steps: 1526 | Train Loss: 1.2920112 Vali Loss: 0.6382990 Test Loss: 1.6633676
Validation loss decreased (inf --> 0.638299). Saving model ...
Updating learning rate to 1e-05
iters: 100, epoch: 2 | loss: 3.1819613
speed: 1.0378s/iter; left time: 14150.4108s
iters: 200, epoch: 2 | loss: 0.6240104
speed: 0.2074s/iter; left time: 2806.6792s
iters: 300, epoch: 2 | loss: 0.4239972
speed: 0.2075s/iter; left time: 2787.2130s
iters: 400, epoch: 2 | loss: 0.5790454
speed: 0.2073s/iter; left time: 2764.3452s
iters: 500, epoch: 2 | loss: 0.5129109
speed: 0.2072s/iter; left time: 2742.8357s
iters: 600, epoch: 2 | loss: 3.0552266
speed: 0.2072s/iter; left time: 2722.1359s
iters: 700, epoch: 2 | loss: 0.6153819
speed: 0.2074s/iter; left time: 2702.9947s
iters: 800, epoch: 2 | loss: 0.6108029
speed: 0.2075s/iter; left time: 2683.7782s
iters: 900, epoch: 2 | loss: 1.0149522
speed: 0.2075s/iter; left time: 2663.1304s
iters: 1000, epoch: 2 | loss: 0.7320828
speed: 0.2075s/iter; left time: 2642.3782s
iters: 1100, epoch: 2 | loss: 0.6959580
speed: 0.2074s/iter; left time: 2620.9557s
iters: 1200, epoch: 2 | loss: 0.4868296
speed: 0.2069s/iter; left time: 2593.7263s
iters: 1300, epoch: 2 | loss: 0.5166126
speed: 0.2069s/iter; left time: 2572.9765s
iters: 1400, epoch: 2 | loss: 2.1325247
speed: 0.2074s/iter; left time: 2557.7465s
iters: 1500, epoch: 2 | loss: 0.5191646
speed: 0.2069s/iter; left time: 2531.3638s
Epoch: 2 cost time: 317.8026850223541
Epoch: 2, Steps: 1526 | Train Loss: 1.2491093 Vali Loss: 0.6379986 Test Loss: 1.6479515
Validation loss decreased (0.638299 --> 0.637999). Saving model ...
Updating learning rate to 5e-06
iters: 100, epoch: 3 | loss: 4.1040535
speed: 1.0396s/iter; left time: 12587.9771s
iters: 200, epoch: 3 | loss: 4.2198677
speed: 0.2125s/iter; left time: 2551.6086s
iters: 300, epoch: 3 | loss: 0.5374264
speed: 0.2089s/iter; left time: 2488.3029s
iters: 400, epoch: 3 | loss: 0.6558690
speed: 0.2074s/iter; left time: 2449.3538s
iters: 500, epoch: 3 | loss: 1.3005149
speed: 0.2074s/iter; left time: 2428.3376s
iters: 600, epoch: 3 | loss: 0.6544358
speed: 0.2079s/iter; left time: 2413.1934s
iters: 700, epoch: 3 | loss: 5.3746767
speed: 0.2080s/iter; left time: 2394.1207s
iters: 800, epoch: 3 | loss: 0.5379453
speed: 0.2110s/iter; left time: 2407.4353s
iters: 900, epoch: 3 | loss: 0.5085211
speed: 0.2121s/iter; left time: 2399.0955s
iters: 1000, epoch: 3 | loss: 2.3799009
speed: 0.2124s/iter; left time: 2381.1714s
iters: 1100, epoch: 3 | loss: 0.6582829
speed: 0.2122s/iter; left time: 2357.6999s
iters: 1200, epoch: 3 | loss: 0.6864679
speed: 0.2121s/iter; left time: 2334.9807s
iters: 1300, epoch: 3 | loss: 0.5495363
speed: 0.2124s/iter; left time: 2317.5838s
iters: 1400, epoch: 3 | loss: 0.4320998
speed: 0.2126s/iter; left time: 2297.7912s
iters: 1500, epoch: 3 | loss: 1.1172121
speed: 0.2122s/iter; left time: 2271.9986s
Epoch: 3 cost time: 322.95352268218994
Epoch: 3, Steps: 1526 | Train Loss: 1.2290818 Vali Loss: 0.6389777 Test Loss: 1.6318545
EarlyStopping counter: 1 out of 3
Updating learning rate to 2.5e-06
iters: 100, epoch: 4 | loss: 6.5205026
speed: 1.1262s/iter; left time: 11918.5769s
iters: 200, epoch: 4 | loss: 0.5527835
speed: 0.2125s/iter; left time: 2227.8205s
iters: 300, epoch: 4 | loss: 0.7205955
speed: 0.2125s/iter; left time: 2206.8931s
iters: 400, epoch: 4 | loss: 0.5857182
speed: 0.2126s/iter; left time: 2185.6987s
iters: 500, epoch: 4 | loss: 1.8298072
speed: 0.2127s/iter; left time: 2165.4811s
iters: 600, epoch: 4 | loss: 3.0394719
speed: 0.2128s/iter; left time: 2145.9223s
iters: 700, epoch: 4 | loss: 2.4748251
speed: 0.2134s/iter; left time: 2129.9469s
iters: 800, epoch: 4 | loss: 0.7085900
speed: 0.2142s/iter; left time: 2117.3976s
iters: 900, epoch: 4 | loss: 0.6424207
speed: 0.2127s/iter; left time: 2081.0393s
iters: 1000, epoch: 4 | loss: 0.7736093
speed: 0.2137s/iter; left time: 2068.8437s
iters: 1100, epoch: 4 | loss: 0.5847422
speed: 0.2156s/iter; left time: 2065.7773s
iters: 1200, epoch: 4 | loss: 0.5024280
speed: 0.2156s/iter; left time: 2044.1739s
iters: 1300, epoch: 4 | loss: 0.5836925
speed: 0.2154s/iter; left time: 2021.3819s
iters: 1400, epoch: 4 | loss: 0.7704700
speed: 0.2155s/iter; left time: 2000.8996s
iters: 1500, epoch: 4 | loss: 0.5966436
speed: 0.2150s/iter; left time: 1974.5776s
Epoch: 4 cost time: 327.7894377708435
Epoch: 4, Steps: 1526 | Train Loss: 1.2139685 Vali Loss: 0.6468018 Test Loss: 1.6328001
EarlyStopping counter: 2 out of 3
Updating learning rate to 1.25e-06
iters: 100, epoch: 5 | loss: 0.6045610
speed: 1.1276s/iter; left time: 10212.5691s
iters: 200, epoch: 5 | loss: 4.1248837
speed: 0.2127s/iter; left time: 1905.1793s
iters: 300, epoch: 5 | loss: 4.0812445
speed: 0.2129s/iter; left time: 1885.6748s
iters: 400, epoch: 5 | loss: 0.6445397
speed: 0.2127s/iter; left time: 1862.5061s
iters: 500, epoch: 5 | loss: 4.0005364
speed: 0.2125s/iter; left time: 1839.6578s
iters: 600, epoch: 5 | loss: 0.6750206
speed: 0.2128s/iter; left time: 1820.5966s
iters: 700, epoch: 5 | loss: 0.9796102
speed: 0.2125s/iter; left time: 1797.1381s
iters: 800, epoch: 5 | loss: 0.5318608
speed: 0.2128s/iter; left time: 1778.5378s
iters: 900, epoch: 5 | loss: 0.5962467
speed: 0.2125s/iter; left time: 1754.2072s
iters: 1000, epoch: 5 | loss: 3.0690393
speed: 0.2125s/iter; left time: 1733.2038s
iters: 1100, epoch: 5 | loss: 0.6859824
speed: 0.2124s/iter; left time: 1711.4450s
iters: 1200, epoch: 5 | loss: 0.6713046
speed: 0.2121s/iter; left time: 1687.7346s
iters: 1300, epoch: 5 | loss: 0.4987230
speed: 0.2118s/iter; left time: 1663.7345s
iters: 1400, epoch: 5 | loss: 0.6661511
speed: 0.2116s/iter; left time: 1641.1604s
iters: 1500, epoch: 5 | loss: 0.5974678
speed: 0.2129s/iter; left time: 1630.4536s
Epoch: 5 cost time: 326.17496824264526
Epoch: 5, Steps: 1526 | Train Loss: 1.2040599 Vali Loss: 0.6492615 Test Loss: 1.6299148
EarlyStopping counter: 3 out of 3
Early stopping
testing : windresult(2)_96_168_Autoformer_windresult(2)_ftM_sl96_ll48_pl168_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_exp_0<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test 13868
test shape: (433, 32, 168, 6) (433, 32, 168, 6)
test shape: (13856, 168, 6) (13856, 168, 6)
mse:1.6479512453079224, mae:0.682569682598114

结果可视化之后:
Figure_1

个人猜想:可能是factors过大导致引入过多的噪音而产生这样的结果?

希望您能为我的问题提供一些解决思路,万分感谢!

Thanks for your autoformer code,but when I try to use instruction "make init ." ,it just stuck here for quite a long time,is this normal?

Downloading and Extracting Packages
dbus-1.13.6 | 604 KB | ########## | 100%
I type this by myself :omitting the unnecessary information for installing dependecy packages
typing_extensions-4. | 27 KB | ########## | 100%
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Installing pip dependencies: ...working...

Training Problem

>>>>>>>start training : ETTm1_96_672_Autoformer_ETTm1_ftM_sl96_ll48_pl672_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0>>>>>>>>>>>>>>>>>>>>>>>>>> train 33793 val 10849 test 10849 iters: 100, epoch: 1 | loss: 0.5350901 speed: 4.5272s/iter; left time: 47358.7275s iters: 200, epoch: 1 | loss: 0.4332319 speed: 4.5712s/iter; left time: 47362.3486s iters: 300, epoch: 1 | loss: 0.4808801 speed: 4.5620s/iter; left time: 46810.8673s iters: 400, epoch: 1 | loss: 0.5168055 speed: 4.5696s/iter; left time: 46431.6680s iters: 500, epoch: 1 | loss: 0.4912913 speed: 4.5852s/iter; left time: 46131.6203s iters: 600, epoch: 1 | loss: 0.4775451 speed: 4.5742s/iter; left time: 45564.0464s iters: 700, epoch: 1 | loss: 0.5060694 speed: 4.5875s/iter; left time: 45237.1464s iters: 800, epoch: 1 | loss: 0.5316107 speed: 4.5767s/iter; left time: 44673.6112s iters: 900, epoch: 1 | loss: 0.4948809 speed: 4.5745s/iter; left time: 44194.6974s iters: 1000, epoch: 1 | loss: 0.4570811 speed: 4.5657s/iter; left time: 43652.2512s Epoch: 1 cost time: 4828.672526597977 Traceback (most recent call last): File "/home/fight/Desktop/Autoformer/Autoformer-main/run.py", line 116, in <module> exp.train(setting) File "/home/fight/Desktop/Autoformer/Autoformer-main/exp/exp_main.py", line 173, in train vali_loss = self.vali(vali_data, vali_loader, criterion) File "/home/fight/Desktop/Autoformer/Autoformer-main/exp/exp_main.py", line 76, in vali outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark) File "/home/fight/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/fight/Desktop/Autoformer/Autoformer-main/models/Autoformer.py", line 90, in forward enc_out, attns = self.encoder(enc_out, attn_mask=enc_self_mask) File "/home/fight/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/fight/Desktop/Autoformer/Autoformer-main/layers/Autoformer_EncDec.py", line 103, in forward x, attn = attn_layer(x, attn_mask=attn_mask) File "/home/fight/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/fight/Desktop/Autoformer/Autoformer-main/layers/Autoformer_EncDec.py", line 69, in forward new_x, attn = self.attention( File "/home/fight/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/fight/Desktop/Autoformer/Autoformer-main/layers/AutoCorrelation.py", line 167, in forward out, attn = self.inner_correlation( File "/home/fight/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/fight/Desktop/Autoformer/Autoformer-main/layers/AutoCorrelation.py", line 135, in forward V = self.time_delay_agg_inference(values.permute(0, 2, 3, 1).contiguous(), corr).permute(0, 3, 1, 2) File "/home/fight/Desktop/Autoformer/Autoformer-main/layers/AutoCorrelation.py", line 66, in time_delay_agg_inference init_index = torch.arange(length).unsqueeze(0).unsqueeze(0).unsqueeze(0).repeat(batch, head, channel, 1).cuda() File "/home/fight/anaconda3/lib/python3.9/site-packages/torch/cuda/__init__.py", line 216, in _lazy_init torch._C._cuda_init() RuntimeError: No CUDA GPUs are available
Hello,author Wu,have you met situation like this?Would you like to give some advice to this question?
This is my configuration
------------------------------------ -+ssssssssssssssssssyyssss+- OS: Ubuntu 18.04.6 LTS x86_64 .ossssssssssssssssssdMMMNysssso. Host: 90Q90022CP ZHENGJIUZHE REN9000 /ssssssssssshdmmNNmmyNMMMMhssssss/ Kernel: 5.4.0-109-generic +ssssssssshmydMMMMMMMNddddyssssssss+ Uptime: 22 days, 8 hours, 7 mins /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/ Packages: 1986 .ssssssssdMMMNhsssssssssshNMMMdssssssss. Shell: bash 4.4.20 +sssshhhyNMMNyssssssssssssyNMMMysssssss+ Resolution: 1920x1080 ossyNMMMNyMMhsssssssssssssshmmmhssssssso DE: GNOME 3.28.4 ossyNMMMNyMMhsssssssssssssshmmmhssssssso WM: GNOME Shell +sssshhhyNMMNyssssssssssssyNMMMysssssss+ WM Theme: Adwaita .ssssssssdMMMNhsssssssssshNMMMdssssssss. Theme: Ambiance [GTK2/3] /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/ Icons: Ubuntu-mono-dark [GTK2/3] +sssssssssdmydMMMMMMMMddddyssssssss+ Terminal: gnome-terminal /ssssssssssshdmNNNNmyNMMMMhssssss/ CPU: Intel i9-10900K (20) @ 5.300GHz .ossssssssssssssssssdMMMNysssso. GPU: NVIDIA NVIDIA Corporation Devic -+sssssssssssssssssyyyssss+- Memory: 21480MiB / 64125MiB

LogsTrans

Hello, is there a comparative experiment of LogTrans, or any Links about LogTrans open source code

Hi I have a few question !

First of all, thank you for such an excellent study.
The results of the Autoformer are awe-inspiring and insightful.

My question is:

  1. I wonder why the autocorrelation result is not [-1,1]. If you look at the result of corr = torchfft.irfft(res, dim = -1) in Autocorrelation.py, there are also values ​​over 10,000. I wonder why this is.

  2. I am curious about the method for circular padding in nn.Conv1d(in_channels=c_in, out_channels=d_model, kernel_size=3, padding=padding, padding_mode='circular', bias=False). I'd appreciate it if you could explain.

How is the ARIMA model Compared with Deep Models?

Hello, I want to know how the baseline experiment of ARIMA is designed in the univariate experimental part?

Especially in test evaluation, how do you use ARIMA to produce, say, L length output? Is it done in an autoregressive way, or use ARIMA to output L variables at one time? And do you re-fit the ARIMA model for every test batch (or step)?

Baseline: Reformer

Hi @wuhaixu2016,
thanks for the great work!

Could I ask how you implemented Reformer in this time series forecasting problem?
In other words, I wonder whether you implemented Reformer in an autoregressive manner (i.e., predict one by one) or in your manner (i.e., predict multiple steps at once like Autoformer).

Lastly, I wonder if you have any plans to release the Reformer code soon.

Thank you!

about normalization and sliding windows

Hi, I'd like to confirm and discuss with you the following details of your experiment:

  1. Z-score normalization is applied for each series, whose params are estimated from training part of individual series. Model predictions are NOT inverse-transformed to the original scale for metric compute. i.e. the MAE and MSE metrics presented in the paper are computed from normalized data. //
    That's not very intuitive, as the result somehow depends on the preprocessing. I've read #6. This configuration seems to be inherited from previous baselines. Is there any rationale for this? I know that if you scale across the entire training set (a scalar \mu and \sigma), you can obtain MAE/MSE of original scale with a constant multiplier. But that's not the case here.

  2. The time window is slided by 1 for next sample. i.e. there's only one new step of info between consecutive samples. //
    I think we can more quickly cover the entire set if sliding by 1 < s <= pred_len. I wonder if it's something stated, or just a small detail that is really up to me?

Sorry for possible silly questions (they're not obvious for me and from the paper

reproduce ETTm2 univariate results in Table 2

Thank you very much for sharing the code!
I can't get univariate prediction results even when I use the scripts. I'm running it with pytorch==1.9.0 and python3.7.
The log is as follow.

Namespace(activation='gelu', batch_size=32, c_out=1, checkpoints='./checkpoints/', d_ff=2048, d_layers=1, d_model=512, data='ETTm2', data_path='ETTm2.csv', dec_in=1, des='Exp', devices='0,1,2,3', distil=True, do_predict=False, dropout=0.05, e_layers=2, embed='timeF', enc_in=1, factor=1, features='S', freq='h', gpu=0, is_training=1, itr=1, label_len=96, learning_rate=0.0001, loss='mse', lradj='type1', model='Autoformer', model_id='ETTm2_96_96', moving_avg=25, n_heads=8, num_workers=10, output_attention=False, patience=3, pred_len=96, root_path='./dataset/ETT-small/', seq_len=96, target='OT', train_epochs=10, use_amp=False, use_gpu=True, use_multi_gpu=False)
Use GPU: cuda:0

start training : ETTm2_96_96_Autoformer_ETTm2_ftS_sl96_ll96_pl96_dm512_nh8_el2_dl1_df2048_fc1_ebtimeF_dtTrue_Exp_0>>>>>>>>>>>>>>>>>>>>>>>>>>
train 34369
val 11425
test 11425
iters: 100, epoch: 1 | loss: 0.0966879
speed: 0.0820s/iter; left time: 872.3655s
iters: 200, epoch: 1 | loss: 0.1096209
speed: 0.0755s/iter; left time: 795.7340s
iters: 300, epoch: 1 | loss: 0.1418100
speed: 0.0757s/iter; left time: 790.5091s
iters: 400, epoch: 1 | loss: 0.0920060
speed: 0.0763s/iter; left time: 789.2272s
iters: 500, epoch: 1 | loss: 0.1261624
speed: 0.0763s/iter; left time: 781.5422s
iters: 600, epoch: 1 | loss: 0.1070141
speed: 0.0767s/iter; left time: 778.2832s
iters: 700, epoch: 1 | loss: 0.0975105
speed: 0.0770s/iter; left time: 773.4665s
iters: 800, epoch: 1 | loss: 0.0870143
speed: 0.0773s/iter; left time: 768.7166s
iters: 900, epoch: 1 | loss: 0.0923501
speed: 0.0772s/iter; left time: 760.1836s
iters: 1000, epoch: 1 | loss: 0.1329619
speed: 0.0775s/iter; left time: 754.6965s
Epoch: 1 cost time: 83.01469206809998
Epoch: 1, Steps: 1074 | Train Loss: 0.1192958 Vali Loss: 0.1495133 Test Loss: 0.1170112
Validation loss decreased (inf --> 0.149513). Saving model ...
Updating learning rate to 0.0001
iters: 100, epoch: 2 | loss: 0.1307557
speed: 0.4428s/iter; left time: 4236.3043s
iters: 200, epoch: 2 | loss: 0.0746148
speed: 0.0738s/iter; left time: 698.9521s
iters: 300, epoch: 2 | loss: 0.0781722
speed: 0.0739s/iter; left time: 692.0664s
iters: 400, epoch: 2 | loss: 0.0840582
speed: 0.0743s/iter; left time: 688.5206s
iters: 500, epoch: 2 | loss: 0.0945234
speed: 0.0742s/iter; left time: 679.8758s
iters: 600, epoch: 2 | loss: 0.1197210
speed: 0.0742s/iter; left time: 672.6283s
iters: 700, epoch: 2 | loss: 0.0902257
speed: 0.0742s/iter; left time: 665.6231s
iters: 800, epoch: 2 | loss: 0.1256524
speed: 0.0742s/iter; left time: 658.1316s
iters: 900, epoch: 2 | loss: 0.1183934
speed: 0.0743s/iter; left time: 651.0201s
iters: 1000, epoch: 2 | loss: 0.0817829
speed: 0.0745s/iter; left time: 645.9785s
Epoch: 2 cost time: 80.55055594444275
Epoch: 2, Steps: 1074 | Train Loss: 0.1038648 Vali Loss: 0.1367796 Test Loss: 0.1242634
Validation loss decreased (0.149513 --> 0.136780). Saving model ...
Updating learning rate to 5e-05
iters: 100, epoch: 3 | loss: 0.1129365
speed: 0.4511s/iter; left time: 3830.8966s
iters: 200, epoch: 3 | loss: 0.1033758
speed: 0.0740s/iter; left time: 621.1884s
iters: 300, epoch: 3 | loss: 0.1275468
speed: 0.0742s/iter; left time: 615.0512s
iters: 400, epoch: 3 | loss: 0.0710122
speed: 0.0745s/iter; left time: 610.2690s
iters: 500, epoch: 3 | loss: 0.0717602
speed: 0.0744s/iter; left time: 602.2747s
iters: 600, epoch: 3 | loss: 0.1175499
speed: 0.0744s/iter; left time: 595.0589s
iters: 700, epoch: 3 | loss: 0.1519643
speed: 0.0749s/iter; left time: 590.9385s
iters: 800, epoch: 3 | loss: 0.0800418
speed: 0.0750s/iter; left time: 584.5540s
iters: 900, epoch: 3 | loss: 0.0746994
speed: 0.0746s/iter; left time: 573.7547s
iters: 1000, epoch: 3 | loss: 0.0830479
speed: 0.0745s/iter; left time: 565.4744s
Epoch: 3 cost time: 80.76482033729553
Epoch: 3, Steps: 1074 | Train Loss: 0.0973873 Vali Loss: 0.1398393 Test Loss: 0.1179208
EarlyStopping counter: 1 out of 3
Updating learning rate to 2.5e-05
iters: 100, epoch: 4 | loss: 0.0736060
speed: 0.4432s/iter; left time: 3287.9202s
iters: 200, epoch: 4 | loss: 0.1116835
speed: 0.0791s/iter; left time: 579.0581s
iters: 300, epoch: 4 | loss: 0.0793331
speed: 0.0791s/iter; left time: 570.8419s
iters: 400, epoch: 4 | loss: 0.0720609
speed: 0.0788s/iter; left time: 560.6287s
iters: 500, epoch: 4 | loss: 0.1089775
speed: 0.0789s/iter; left time: 553.9732s
iters: 600, epoch: 4 | loss: 0.0835999
speed: 0.0786s/iter; left time: 544.0225s
iters: 700, epoch: 4 | loss: 0.1258804
speed: 0.0786s/iter; left time: 536.2984s
iters: 800, epoch: 4 | loss: 0.0553840
speed: 0.0783s/iter; left time: 526.0710s
iters: 900, epoch: 4 | loss: 0.0811464
speed: 0.0788s/iter; left time: 521.5191s
iters: 1000, epoch: 4 | loss: 0.1213600
speed: 0.0785s/iter; left time: 511.5148s
Epoch: 4 cost time: 85.34881067276001
Epoch: 4, Steps: 1074 | Train Loss: 0.0949577 Vali Loss: 0.1529772 Test Loss: 0.1448818
EarlyStopping counter: 2 out of 3
Updating learning rate to 1.25e-05
iters: 100, epoch: 5 | loss: 0.0767112
speed: 0.4476s/iter; left time: 2840.0901s
iters: 200, epoch: 5 | loss: 0.0909449
speed: 0.0783s/iter; left time: 488.9913s
iters: 300, epoch: 5 | loss: 0.1096216
speed: 0.0781s/iter; left time: 480.1752s
iters: 400, epoch: 5 | loss: 0.1170162
speed: 0.0787s/iter; left time: 475.6964s
iters: 500, epoch: 5 | loss: 0.0840287
speed: 0.0778s/iter; left time: 462.4421s
iters: 600, epoch: 5 | loss: 0.0611459
speed: 0.0773s/iter; left time: 451.9506s
iters: 700, epoch: 5 | loss: 0.0679403
speed: 0.0777s/iter; left time: 446.5334s
iters: 800, epoch: 5 | loss: 0.0693620
speed: 0.0783s/iter; left time: 442.0431s
iters: 900, epoch: 5 | loss: 0.1007061
speed: 0.0784s/iter; left time: 434.5144s
iters: 1000, epoch: 5 | loss: 0.0944251
speed: 0.0783s/iter; left time: 426.3235s
Epoch: 5 cost time: 84.73156476020813
Epoch: 5, Steps: 1074 | Train Loss: 0.0931660 Vali Loss: 0.1550726 Test Loss: 0.1493730
EarlyStopping counter: 3 out of 3
Early stopping
testing : ETTm2_96_96_Autoformer_ETTm2_ftS_sl96_ll96_pl96_dm512_nh8_el2_dl1_df2048_fc1_ebtimeF_dtTrue_Exp_0<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test 11425
test shape: (357, 32, 96, 1) (357, 32, 96, 1)
test shape: (11424, 96, 1) (11424, 96, 1)
mse:0.12426342070102692, mae:0.24697716534137726

Similar results are observed with unfixed random seed and itr=3. Are there any other tips for reproducing this work?

export CUDA_VISIBLE_DEVICES=1 disables CUDA

Nice work!

I noticed though that on systems with 1 GPU, by default the scripts train on CPU. This is due to the bash files containing

export CUDA_VISIBLE_DEVICES=1

The issue is if you do this on a system with a single GPU the following returns false

torch.cuda.is_available()

Since the first GPU (normally) starts at 0

Mask in decoder

Thank you for the well-commented code. The causal mask operation is not used in the decoder's auto-corrleration layer, which is different from mask self-attention in orignal Transformer. Is my understanding correct?

Reproducing results

Hi, Thank you so much for your code and I really like your interesting paper.
I have a question on generating the results. When I use the docker and run the script I get:

ECL_96_96_Autoformer_custom_ftM_sl96_ll48_pl96_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0
mse:0.20583173632621765, mae:0.3203032612800598

ECL_96_192_Autoformer_custom_ftM_sl96_ll48_pl192_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0
mse:0.24435684084892273, mae:0.34420478343963623

ECL_96_336_Autoformer_custom_ftM_sl96_ll48_pl336_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0
mse:0.23177462816238403, mae:0.3394138813018799

ECL_96_720_Autoformer_custom_ftM_sl96_ll48_pl720_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0
mse:0.2570257782936096, mae:0.35937315225601196

Although they are very close to the reported number, In the paper, it says each number is after 3 experiments, I was wondering should I change the iteration to 3 in the script to get the exact numbers? In another recent paper I saw they got the same numbers using an average of 8 experiments.

Inverse Transformation of the Data while Plotting Ground Truth Vs Prediction

Good Day,
I'm currently working on the forecasting of Univariant time series using your Autoformer in google colab.
I've attached the dataset I'm using below and I am currently trying to predict the Voltage data in the dataset.

dataset4.csv

After the Prediction of the test data, the prediction and ground truth values are plotted however they are not scaled back to their original values.
I want your help in doing this.

I've made the some changes in the run.py and data_factory.py to fit my custom dataset in the code below

run.py.pdf

  • Line 69 I've added a new line of code: parser.add_argument('--inverse', action='store_true', help='inverse output data', default=False)
    and made some changes with the epochs and enc_in , dec_in and c_out values.

data_factory.py.pdf

  • Line 9 I've inserted dataset4 as the custom data set.

After running the code :
!python run.py --is_training 1 --model_id test --model Informer --data dataset4

I was able to train the model and run it on test data and got the corresponding MAE and MSE values

This is the code used to Plot the results:

%cd /content/drive/MyDrive/Autoformer_main/Autoformer-main/results/test_Informer_dataset4_ftM_sl96_ll48_pl24_dm512_nh8_el2_dl1_df2048_fc5_ebtimeF_dtTrue_test_0 !ls

import numpy as np preds = np.load('pred.npy') trues = np.load('true.npy') import matplotlib.pyplot as plt import seaborn as sns

import matplotlib.pyplot as plt plt.figure() plt.plot (trues[:,1,-1], label='GroundTruth') plt.plot (preds[:,1,-1], label='Prediction') plt.legend() from google.colab import files plt.show()

In the Plot below you can see that the ground truth value of Voltage is between -2 and 1:

image

but if you look at the original dataset, I've plotted the ground Truth value of voltage and its is between 3 and 4.5 as shown below:

image

You are using Standard scaler to scale the data, however I am unable to re-scale the standardized data back to its original values while plotting both the ground truth and prediction value.

Please help in using the inverse transform to re-scale my data and predictions back to its original values.

Thank you

The weird same result with Informer

当我使用如下和论文一致的配置训练ETTm2时,取得的结果是 mse:0.08926962316036224, mae:0.22885815799236298
这和论文里的Informer的0.088, 0.225是差不多的,请问是数值有误还是我设置的哪里有问题嘛
(activation='gelu', batch_size=32, c_out=1, checkpoints='./checkpoints/', d_ff=2048, d_layers=1, d_model=512, data='ETTm2', data_path='ETTm2.csv', dec_in=1, des='test', device_ids=[0, 1, 2, 3], devices='0,1,2,3', distil=True, do_predict=False, dropout=0.05, dvices='0,1,2,3', e_layers=2, embed='timeF', enc_in=1, factor=1, features='S', freq='h', gpu=0, is_training=1, itr=1, label_len=48, learning_rate=0.0001, loss='mse', lradj='type1', model='Autoformer', model_id='ETTm2_96_96', moving_avg=25, n_heads=8, num_workers=10, output_attention=False, patience=3, pred_len=96, root_path='./data/ETT/', seq_len=96, target='OT', train_epochs=10, use_amp=False, use_gpu=True, use_multi_gpu=True)
Use GPU: cuda:0

我后来发现是label_len设置的是48而不是96, 这个会对结果有什么影响吗

do_predict上的一些问题

在现实数据集上运行do_predict, autoformer模型能够顺利出结果,但是同样的参数设置下informer和transformer出现报错,如下:

Traceback (most recent call last):
File "run.py", line 121, in
exp.predict(setting, True)
File "/share/home/luozicong/transformer-based model/Autoformer-main/exp/exp_main.py", line 311, in predict
outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)
File "/share/home/luozicong/anaconda3/envs/transformer/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/share/home/luozicong/transformer-based model/Autoformer-main/models/Informer.py", line 74, in forward
dec_out = self.dec_embedding(x_dec, x_mark_dec)
File "/share/home/luozicong/anaconda3/envs/transformer/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/share/home/luozicong/transformer-based model/Autoformer-main/layers/Embed.py", line 117, in forward
x = self.value_embedding(x) + self.temporal_embedding(x_mark) + self.position_embedding(x)
RuntimeError:` The size of tensor a (48) must match the size of tensor b (96) at non-singleton dimension 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.