thuml / Autoformer

About Code release for "Autoformer: Decomposition Transformers with Auto-Correlation for Long-Term Series Forecasting" (NeurIPS 2021), https://arxiv.org/abs/2106.13008
MIT License
2k stars 429 forks source link

--do_predict does not handle --features MS correctly #182

Closed mw66 closed 1 year ago

mw66 commented 1 year ago

With --features M, the test output pred.npy shape is (1422, 96, 8), and real_prediction.npy shape is (1, 96, 8)

With --features MS, the test output pred.npy shape is (1422, 96, 1), and real_prediction.npy shape is still (1, 96, 8)

>>> import numpy as np
>>> p = np.load("./results/Exchange_96_96_Autoformer_custom_ftMS_sl96_ll48_pl96_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0/pred.npy")
>>> p.shape
(1422, 96, 1)
>>> p = np.load("./results/Exchange_96_96_Autoformer_custom_ftM_sl96_ll48_pl96_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0/pred.npy")
>>> p.shape
(1422, 96, 8)
>>> p = np.load("./results/Exchange_96_96_Autoformer_custom_ftMS_sl96_ll48_pl96_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0/real_prediction.npy")
>>> p.shape
(1, 96, 8)
>>> p = np.load("./results/Exchange_96_96_Autoformer_custom_ftM_sl96_ll48_pl96_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0/real_prediction.npy")
>>> p.shape
(1, 96, 8)
mw66 commented 1 year ago

specfiically:

the following line are in vali(), train(), and test()

                f_dim = -1 if self.args.features == 'MS' else 0

https://github.com/thuml/Autoformer/blob/main/exp/exp_main.py#L77 https://github.com/thuml/Autoformer/blob/main/exp/exp_main.py#L138 https://github.com/thuml/Autoformer/blob/main/exp/exp_main.py#L149 https://github.com/thuml/Autoformer/blob/main/exp/exp_main.py#L228

BUT is not in predict(): https://github.com/thuml/Autoformer/blob/main/exp/exp_main.py#L305

You really should re-factor this into a separate function to avoid code duplication.

mw66 commented 1 year ago

this file has too much code-duplcation:

https://github.com/thuml/Autoformer/blob/main/exp/exp_main.py#L62-L79

You guys copy & paste code? unbelievable!

wuhaixu2016 commented 1 year ago

Hi, thanks for your commit. We have made the code cleaner.