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

Different Inputs for use_amp flag, not sure if this is a bug. #96

Closed yihaocs closed 2 years ago

yihaocs commented 2 years ago

Hello,

I found that the inputs for the model is different when you use use_amp or not in your implementation: https://github.com/thuml/Autoformer/blob/main/exp/exp_main.py#L132-L147

In the code, if args.use_amp==True & args.output_attention==False, then we have


outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)  # L136

If if args.use_amp==False & args.output_attention==False, then we have


outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark, batch_y) # L147

Is this specifically designed, or is this a bug? Because I find the implementation in the informer repo, they are consistent:

https://github.com/zhouhaoyi/Informer2020/blob/main/exp/exp_informer.py#L259-L283 :


if self.args.use_amp:
    with torch.cuda.amp.autocast():
        if self.args.output_attention:
            outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)[0]
        else:
            outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)
else:
    if self.args.output_attention:
        outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)[0]
    else:
        outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)

Thanks

wuhaixu2016 commented 2 years ago

Sorry for this typo. We have fixed this in the latest commit.