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

Case where edge_index varies for each batch #152

Closed rperera12 closed 2 years ago

rperera12 commented 2 years ago

Hi, Great Library! I have a quick question regarding a case similar to the example from notebook: a3tgcn_for_traffic_forecasting.ipynb In this example:

1) x.shape = [batch_size, num_nodes, num_nodes_features, timesteps],
2) edge_index.shape = [2, num_edges]

In other words, for all time-steps in the input and for all batches the graph's edges remains static/unchanged. However, I am dealing with the case where for each time-step I will have a different edge_index. I can easily overcome the issue of time-step varying edge_index and/or batch varying edge_index using a zero padding approach. However, when I use the model A3TGCN2 along with the provided class TemporalGNN, these do not include batches for edge_index. Is there a way to include batches for the edge_index as well in these models. Even though I am setting the edge_index tensors to have the same size using the padding approach, each batch-wise edge_index will have different configuration, and I'd like to be able to use them in the model as well.

benedekrozemberczki commented 2 years ago

Do you want to extend the generator classes?

rperera12 commented 2 years ago

Thanks for your response! On this example a3tgcn_for_traffic_forecasting.ipynb the edge_index have dimensions [2,num_edges]. They don’t include batch size since the graph is static. I’d like to include different edge_index for each batch such that edge_index.shape = [batch, 2, num_edges]. The model used in this example does not handle batches. Please if there is a way you could include this model A3TGCN2 to handle batches in the edge_index it would be extremely helpful

benedekrozemberczki commented 2 years ago

Even basic GCN batching operates differently; I recommend reading about that first.

Message ID: <benedekrozemberczki/pytorch_geometric_temporal/issues/152/1088694705@ github.com>

rperera12 commented 2 years ago

I’m not sure if you are referring to the Graph Geometric approach, I am using Graph Geometric Temporal, specifically, my problem is very similar to the example from the notebook you provide in this repo, A3TGCN2. Here, your batches go in the first dimension (e.g., x.shape = [batches, num_nodes, num_node_features, timesteps]. I am indeed using this approach for my problem. The only difference is that in the example provided the edges are static, basically the same throughout, that is why you don’t have different edges at different batches, or even at the different time steps. I am wondering if it is possible to include this for this model

benedekrozemberczki commented 2 years ago

Yes, again different edge sets should not be a problem, you can exploit the edge weights or something else for batching.

On Tue, 5 Apr 2022 at 14:30, Roberto Perera Aguiar @.***> wrote:

I’m not sure if you are referring to the Graph Geometric approach, I am using Graph Geometric Temporal, specifically, my problem is very similar to the example from the notebook you provide in this repo, A3TGCN2. Here, your batches go in the first dimension (e.g., x.shape = [batches, num_nodes, num_node_features, timesteps]. I am indeed using this approach for my problem. The only difference is that in the example provided the edges are static, basically the same throughout, that is why you don’t have different edges at different batches, or even at the different time steps. I am wondering if it is possible to include this for this model

— Reply to this email directly, view it on GitHub https://github.com/benedekrozemberczki/pytorch_geometric_temporal/issues/152#issuecomment-1088706954, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEETMF6EOER3TTCDRL45HF3VDQ6ABANCNFSM5SQLXWZQ . You are receiving this because you commented.Message ID: <benedekrozemberczki/pytorch_geometric_temporal/issues/152/1088706954@ github.com>