Models API¶
Supervised ¶
Supervised(config: Dict, in_channels: int, num_classes: int)
Bases: BaseSSLModel
Encoder + linear head, with CrossEntropyLoss or — task: regression — L1 loss.
For regression num_classes is the number of targets and data.y holds floats.
The labels the loss may see depend on the mode:
- Graph-level (
encoder.pool=True): node embeddings are mean-pooled per graph and every graph in the batch contributes. - Node-level mini-batch (
batch.batch_sizeset byNeighborLoader): only the firstbatch_sizeseed nodes contribute. Build the loader withinput_nodes=train_idx. - Node-level full-batch: only
data.train_masknodes contribute. A full graph withouttrain_maskraises rather than silently training on validation/test labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Dict
|
Config dict validated against SupervisedConfig. |
required |
in_channels
|
int
|
Node feature dimensionality, resolved from the dataset. |
required |
num_classes
|
int
|
Number of output classes, resolved from the dataset. |
required |
Source code in src/graphssl/models/supervised.py
38 39 40 41 42 43 44 45 | |
DGI ¶
DGI(config: Dict, in_channels: int)
Bases: BaseSSLModel
Mutual information maximisation between node embeddings and global summary.
Discriminates real node embeddings from a corrupted-graph counterpart using a learnable bilinear discriminator W (DGI, Velickovic et al. 2019).
The summary vector s is computed as sigmoid(mean(h_pos)). For graph-level
mode (encoder.pool=True) one summary per graph is computed and broadcast
to the corresponding nodes via the batch index. On a NeighborLoader batch
only the seed nodes (the first batch_size) enter the summary and the loss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Dict
|
Config dict validated against DGIConfig. |
required |
in_channels
|
int
|
Node feature dimensionality, resolved from the dataset. |
required |
Source code in src/graphssl/models/dgi.py
36 37 38 39 40 41 42 43 44 45 46 | |
GraphCL ¶
GraphCL(config: Dict, in_channels: int)
Bases: BaseSSLModel
NT-Xent contrastive loss over two independently augmented views.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Dict
|
Config dict validated against GraphCLConfig. |
required |
in_channels
|
int
|
Node feature dimensionality, resolved from the dataset. |
required |
Source code in src/graphssl/models/graphcl.py
29 30 31 32 33 34 35 36 37 38 | |
BGRL ¶
BGRL(config: Dict, in_channels: int)
Bases: BaseSSLModel
Teacher-student SSL with EMA target encoder and cosine regression loss.
Key invariant: the target encoder is deepcopied then reset via reset_parameters(), giving it intentionally different initial weights. This asymmetry is critical for convergence (App. B, BGRL paper).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Dict
|
Config dict validated against BGRLConfig. |
required |
in_channels
|
int
|
Node feature dimensionality, resolved from the dataset. |
required |
Source code in src/graphssl/models/bgrl.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
AFGRL ¶
AFGRL(config: Dict, in_channels: int)
Bases: BaseSSLModel
No-augmentation SSL: positive pairs mined via local adjacency and global k-means.
Identical to BGRL in the student/teacher setup, but replaces augmented views with node pairs identified as positives through: - Local: top-k cosine-similarity neighbours that are also graph-adjacent (kNN ∩ adj). - Global: top-k neighbours sharing a k-means cluster in ANY of the independent runs.
Key difference from BGRL: the target encoder starts with the same weights as the online encoder (deepcopy without reset). Diversity comes from the miner, not from weight asymmetry.
Graph-level mode: the PositiveMiner is topology-aware and not meaningful across independent graphs. In this mode it is skipped; a simple teacher-student loss on pooled embeddings is used instead.
Requires faiss-cpu: pip install faiss-cpu
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Dict
|
Config dict validated against AFGRLConfig. |
required |
in_channels
|
int
|
Node feature dimensionality, resolved from the dataset. |
required |
Source code in src/graphssl/models/afgrl.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
VICReg ¶
VICReg(config: Dict, in_channels: int)
Bases: BaseSSLModel
Symmetric augmentation with triple VICReg loss (invariance + variance + covariance).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Dict
|
Config dict validated against VICRegConfig. |
required |
in_channels
|
int
|
Node feature dimensionality, resolved from the dataset. |
required |
Source code in src/graphssl/models/vicreg.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
BarlowTwins ¶
BarlowTwins(config: Dict, in_channels: int)
Bases: BaseSSLModel
Barlow Twins cross-correlation loss with symmetric augmentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Dict
|
Config dict validated against BarlowTwinsConfig. |
required |
in_channels
|
int
|
Node feature dimensionality, resolved from the dataset. |
required |
Source code in src/graphssl/models/barlow_twins.py
29 30 31 32 33 34 35 36 37 38 | |
GraphDINO ¶
GraphDINO(config: Dict, in_channels: int)
Bases: BaseSSLModel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Dict
|
Config dict (see graphdino.yaml); validated against GraphDINOConfig. |
required |
in_channels
|
int
|
Node feature size, resolved from the dataset at runtime. |
required |
Source code in src/graphssl/models/graphdino.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |