New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GPSE Implementation #9018
base: master
Are you sure you want to change the base?
GPSE Implementation #9018
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9018 +/- ##
==========================================
+ Coverage 88.46% 89.23% +0.76%
==========================================
Files 470 472 +2
Lines 30189 30594 +405
==========================================
+ Hits 26708 27301 +593
+ Misses 3481 3293 -188 ☔ View full report in Codecov by Sentry. |
Graph Positional and Structural Encoder implementation as per #8310. Adapted from the original repository: https://github.com/G-Taxonomy-Workgroup/GPSE. This version is a standalone implementation that is decoupled from GraphGym, and thus aims for better accessibility and a smoother integration into PyG. While the priority of this PR is to enable loading and using pre-trained models in plug-and-play fashion, it also includes the custom loss function used to train the model. Nevertheless, it might be easier to use the original repository for pre-training and fine-tuning new GPSE models for the time being.
This PR includes the following:
GPSE
: The main GPSE module, that generates learned encodings for input graphs.FeatureEncoder
,GNNStackStage
,IdentityHead
,GNNInductiveHybridMultiHead
,ResGatedGCNConvGraphGymLayer
,Linear
,MLP
,GeneralMultiLayer
,GeneralLayer
,BatchNorm1dNode
,BatchNorm1dEdge
,VirtualNodePatchSingleton
) and wrapper functions (GNNPreMP
,GNNLayer
), all adapted from their GraphGym versions for compatibility and enabling the loading of weights pre-trained using the GraphGym/original version.GPSE.from_pretrained()
that returns a model with pre-trained weights from the original repository/Zenodo files.GPSENodeEncoder
, a helper linear/MLP encoder that takes the GPSE encodings precomputed asbatch.pestat_GPSE
in the input graphs, maps them to a desired dimension and appends them to node features.precompute_GPSE
, a function that takes in a GPSE model and a dataset, and precomputes GPSE encodings in-place for a given dataset using the helper functiongpse_process_batch
.AddGPSE
, which in similar fashion toAddLaplacianEigenvectorPE
andAddRandomWalkPE
adds the GPSE encodings to a given graph using the helper functiongpse_process
test/test_gpse.py
andtest/test_add_gpse.py
.gpse_loss
and helper functionscosim_col_sep
andprocess_batch_idx
used in GPSE training.A comprehensive example in[EDIT: To be added as a separate PR]examples/gpse.py
using the ZINC dataset. Two different ways of using GPSE to generate encodings is demonstrated: (a) as a function that adds encodings in-place throughprecompute_GPSE
, (b) as a pre-transform.