Informer must except pred_len > 1
Hadar933 opened this issue · comments
when using the Informer
model and a pred_len == 1
, we observe an index error
IndexError: max(): Expected reduction dim 2 to have non-zero size
the reason, we believe, is this:
- the
forward
method takes inx_dec
that has shape(b,1,f)
and called in theself.decoder
module (aDecoderLayer
layer) - inside, a self-attention mechanism is performed with
x_dec
(denoted withx
), which in turn called theself.inner_attention
module, which is theforward
call of theProbAttention
class. - in this step,
keys=x=x_dec
, hence the line_, L_K, _, _ = keys.shape
setsL_K == 1
, which in turns setsU_part
to0
as there is a log taken overL_K
in the definitionU_part = self.factor * np.ceil(np.log(L_K)).astype('int').item() # c*ln(L_k)
- the last call is the
_prob_QK
method of theProbAttention
class, that performsM = Q_K_sample.max(-1)[0] - torch.div(Q_K_sample.sum(-1), L_K)
, resulting ina IndexError: max(): Expected reduction dim 2 to have non-zero size
. (Q_K_sample
is an empty tensor)
the command we used is:
python run_longExp.py --is_training 1 --root_path ./dataset/ --data_path ETTh1.csv --model_id ETTh1_96 --model Informer --data ETTh1 --features M --seq_len 128 --pred_len 1 --label_len 0 --enc_in 7 --des Exp --itr 1 --batch_size 32 --learning_rate 0.005