PyG-SSL Datasetsο
Before using PyG-SSL, you need to convert your dataset into torch_geometric.data.Dataset, as we use the data structure and loader from torch_geometric for accelerated computation.
Augmentο
PyG-SSL provides many standard augmentations to use for creating positive and negative examples.
- class RandomDropNode(is_x: bool = True, is_adj: bool = False, drop_percent=0.2)ο
Randomly drop a percentage of nodes or edges from the graph.
Parameters:ο
- is_x (bool, optional):
Whether to drop nodes from the feature matrix. Default is True.
- is_adj (bool, optional):
Whether to drop edges from the adjacency matrix. Default is False.
- drop_percent (float, optional):
The percentage of nodes or edges to drop. Default is 0.2.
- class RandomDropEdge(is_x: bool = True, is_adj: bool = False, drop_percent=0.2)ο
Randomly drop a percentage of edges or edges from the graph.
Parameters:ο
- is_x (bool, optional):
Whether to drop nodes from the feature matrix. Default is True.
- is_adj (bool, optional):
Whether to drop edges from the adjacency matrix. Default is False.
- drop_percent (float, optional):
The percentage of nodes or edges to drop. Default is 0.2.
- class RandomMask(is_x: bool = True, is_adj: bool = False, drop_percent=0.2)ο
Randomly mask a percentage of nodes features from the graph.
Parameters:ο
- is_x (bool, optional):
Whether to drop nodes from the feature matrix. Default is True.
- is_adj (bool, optional):
Whether to drop edges from the adjacency matrix. Default is False.
- drop_percent (float, optional):
The percentage of nodes or edges to drop. Default is 0.2.
- class RandomMaskChannel(is_x: bool = True, is_adj: bool = False, drop_percent=0.2)ο
Similar to RandomMask, but mask a percentage of feature channels of the nodes.
Parameters:ο
- is_x (bool, optional):
Whether to drop nodes from the feature matrix. Default is True.
- is_adj (bool, optional):
Whether to drop edges from the adjacency matrix. Default is False.
- drop_percent (float, optional):
The percentage of nodes or edges to drop. Default is 0.2.
- class AugmentSubgraph(is_x: bool = True, is_adj: bool = False, drop_percent=0.2)ο
Randomly drop a percentage subgraph from the graph.
Parameters:ο
- is_x (bool, optional):
Whether to drop nodes from the feature matrix. Default is True.
- is_adj (bool, optional):
Whether to drop edges from the adjacency matrix. Default is False.
- drop_percent (float, optional):
The percentage of nodes or edges to drop. Default is 0.2.
- class NeighborSearch_AFGRL(device='cuda', num_centroids=100, num_kmeans=5, clus_num_iters=20)ο
Neighbor search for AFGRL.
Parameters:ο
- device (str, optional):
Device to use for computation. Default is βcudaβ.
- num_centroids (int, optional):
Number of centroids to use for clustering. Default is 100.
- num_kmeans (int, optional):
Number of k-means to use for clustering. Default is 5.
- clus_num_iters (int, optional):
Number of iterations for clustering. Default is 20.
- class SumEmb(pooler: str = 'avg', act: Callable | None = None)ο
Get the summary for a batch of embeddings.
Parameters:ο
- pooler (str, optional):
βavgβ or βmaxβ, specifies how to generate global embeddings. Default is βavgβ.
- act (Callable, optional):
Activation function for the encoder. Default is None.
Transformο
- class TransformList(transform_list: List[Callable])ο
A list of transform function
Parameters:ο
- transform_list (List[Callable]):
A list of transform functions to apply.
- class Edge2Adj(norm: Callable | None = None)ο
Convert edge to adjacency matrix.
Parameters:ο
- norm (Optional[Callable]): Normalization of the adjacency matrix.
(default: None) None: Generate 0/1 adjacency matrix from edge_index & edge_attr/edge_weight.
- class GCNNorm(add_self_loops: int = 1)ο
Applies the GCN normalization from the βSemi-supervised Classification with Graph Convolutional Networksβ paper (functional name:
gcn_norm).\[\mathbf{\hat{A}} = \mathbf{\hat{D}}^{-1/2} (\mathbf{A} + \mathbf{I}) \mathbf{\hat{D}}^{-1/2}\]where \(\hat{D}_{ii} = \sum_{j=0} \hat{A}_{ij} + 1\).
Parameters:ο
- add_self_loops (int, optional):
Number of self loops to add to the adjacency matrix. Default is 1.
- class NormalizeFeatures(attrs: List[str] = ['x'], ord: Any | None = None)ο
Row-normalizes the attributes given in
attrsto sum-up to one (functional name:normalize_features).Parameters:ο
- attrs (List[str]): The names of attributes to normalize.
(default:
["x"])
- ord (Optional[str, int, float]): The order of normalization.
(default: βsum1β) sum1: x = x - min(x), x / sum(x) other supported normalization: https://pytorch.org/docs/stable/generated/torch.linalg.norm.html#torch.linalg.norm