benedekrozemberczki / pytorch_geometric_temporal

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

How to batch this specific use-case. #134

Closed BraveDistribution closed 2 years ago

BraveDistribution commented 2 years ago

In the first place, let me thank you for this library.

I have a specific scenario and I'd like to use your library to implement it, however I haven't found an example in the docs.

Simplified example: We have 10 graphs that depicts spheres (mesh of a sphere). The spheres are moving on a plane (so each node has a feature "x", that is being changed over time. The edge connectivity stays the same. Though, each sphere consists of different number of nodes. (Imagine a scenario that bigger spheres are moving faster and smaller slower)

Now, let's say I have a temporal sequence of 100 time snapshots for each sphere. I want to train a Temporal Graph Neural Network to predict the motion of the spheres.

Is this possible through your library? I thought about creating a batches of the data - and each batch will include only data from one sphere and divide it into [0, X] for train and [X+3] for test.

Thanks.

benedekrozemberczki commented 2 years ago

Hi there, you should use diagonal batching. You have a static graph with changing signal, the direct indexing of snapshots allows arbitrary splits.

BraveDistribution commented 2 years ago

Got it.

If I understand you correctly, this will be a good reference for other people:

https://pytorch-geometric.readthedocs.io/en/latest/notes/batching.html

So, just combine all the graphs into one big graph, but the subgraphs will not be connected. I'll post here a reference to an example sheet if I am able to make it work.

benedekrozemberczki commented 2 years ago

Exacty, that is what you need. Happy to guid you throughtcontributing and merge your code later. Do you want to share the data too?

BraveDistribution commented 2 years ago

I'll share the data and code once I get it to work. Thanks! I'll submit a PR.