benedekrozemberczki / pytorch_geometric_temporal

PyTorch Geometric Temporal: Spatiotemporal Signal Processing with Neural Machine Learning Models (CIKM 2021)
MIT License
2.66k stars 377 forks source link

mpnn_lstm what is actually window? #174

Closed michelegentili93 closed 2 years ago

michelegentili93 commented 2 years ago

Hi,

I've tried the Chickenpox example. I don't understand... the dataset is [n_nodes x window], where window is the number of observations in each node. In the documentations it's written: window (int): Number of past samples included in the input. However if in your example I just switch in_channels with window, i.e. MPNNLSTM(1, 32, 32, 20, 4, 0.5), then I get this error: RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

I'm probably misunderstanding what's the window parameter, could you give more details?

Thanks!

SherylHYX commented 2 years ago

in_channels is not the same as window, but in_channels is a parameter telling the neural network about the input node feature dimension.

michelegentili93 commented 2 years ago

Thanks for the quick response! I understand they are different. I don't understand though the use. The observation on Chickenpox represent the same value in different time stamp (and different nodes of course). So I don't understand why would it be count in in_channels (which represent the n of features, and it should be only 1) rather than window. My understanding is that window is the size of the rolling window that generate a temporal dataset. What am I missing?

Let say X is the input matrix, then how do the dimension works? (n_nodes, n_features, window)?

michelegentili93 commented 2 years ago

Sorry to reopen... but it doesn't work with X having this dimensions: (n_nodes, n_features, window). If I run your example of MPNNLSTM and switch node features with window, even if I reshape the x, it doesn't work and I get this error:

[/usr/local/lib/python3.7/dist-packages/torch_geometric_temporal/nn/recurrent/mpnn_lstm.py] in forward(self, X, edge_index, edge_weight) 80 R = list() 81 ---> 82 S = X.view(-1, self.window, self.num_nodes, self.in_channels)

RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

I changed the model definition: self.recurrent = MPNNLSTM(1, 32, 32, 20, node_features, 0.5) and the input x in the snapshot: snapshot.x = snapshot.x.reshape(20,1,4)