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 ShuffleNode

Shuffle the nodes in the graph.

Parameters:

  • None

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 attrs to sum-up to one (functional name: normalize_features).

Parameters: