ML4ITS / mtad-gat-pytorch

PyTorch implementation of MTAD-GAT (Multivariate Time-Series Anomaly Detection via Graph Attention Networks) by Zhao et. al (2020, https://arxiv.org/abs/2009.02040).
MIT License
328 stars 76 forks source link

FC layer out_dim not matching RECOn layer in_dim #18

Closed krenusz closed 2 years ago

krenusz commented 2 years ago

I have run into a logic issue at the point where the Forecast layer output goes into the Reconstruction layer.

`gru_n_layers=1 in_dim=150 out_dim = 8 #Output dimension of the FC layer forecast_n_layers=1 forecast_hid_dim=150 n_layers=1 hid_dim=150 window_size = 20

dropout = 0.0 if n_layers == 1 else dropout rnn = nn.GRU(in_dim, hid_dim, n_layers, batch_first=True, dropout=dropout) print(rnn)

fc = nn.Linear(hid_dim, out_dim) print(fc)

h_finalend = x print(h_final_end.shape) h_final_end_rep = h_final_end.repeat_interleave(windowsize, dim=1).view(x.size(0), window_size, -1) print(h_final_end_rep.shape) decoderout, = rnn(h_final_end_rep) print(decoder_out.shape) out = fc(decoder_out) print(out.shape)`

The Forecast layer output dimension is 8 referring to n_features and the the Reconstruction layer input dimension is 150 referring to gru_hid_dim.

running separetly in notebook i got the error: RuntimeError: input.size(-1) must be equal to input_size. Expected 150, got 8

I must missed something:(

krenusz commented 2 years ago

n_features and window_size parameters i set it wrong, but the issue is still presenting

krenusz commented 2 years ago

Found the answer!