PyTorch Geometric Backend

Models

class autogl.module.model.pyg.AutoTopkpool(num_features=None, num_classes=None, device=None, init=False, num_graph_features=0, **args)[source]

AutoTopkpool. The model used in this automodel is from https://arxiv.org/abs/1905.05178, https://arxiv.org/abs/1905.02850

Parameters:
  • num_features (int.) – The dimension of features.
  • num_classes (int.) – The number of classes.
  • device (torch.device or str) – The device where model will be running on.
  • init (bool.) – If True(False), the model will (not) be initialized.
class autogl.module.model.pyg.AutoSAGE(num_features=None, num_classes=None, device=None, **args)[source]

AutoSAGE. The model used in this automodel is GraphSAGE, i.e., the GraphSAGE from the “Inductive Representation Learning on Large Graphs” paper. The layer is

\[\mathbf{x}^{\prime}_i = \mathbf{W}_1 \mathbf{x}_i + \mathbf{W_2} \cdot \mathrm{mean}_{j \in \mathcal{N(i)}} \mathbf{x}_j\]
Parameters:
  • num_features (int.) – The dimension of features.
  • num_classes (int.) – The number of classes.
  • device (torch.device or str) – The device where model will be running on.
  • init (bool.) – If True(False), the model will (not) be initialized.
class autogl.module.model.pyg.GraphSAINTAggregationModel(num_features: int = Ellipsis, num_classes: int = Ellipsis, device: Union[str, torch.device] = Ellipsis, init: bool = False, **kwargs)[source]
class autogl.module.model.pyg.AutoGCN(num_features: int = Ellipsis, num_classes: int = Ellipsis, device: Union[str, torch.device] = Ellipsis, **kwargs)[source]

AutoGCN. The model used in this automodel is GCN, i.e., the graph convolutional network from the “Semi-supervised Classification with Graph Convolutional Networks” paper. The layer is

\[\mathbf{X}^{\prime} = \mathbf{\hat{D}}^{-1/2} \mathbf{\hat{A}} \mathbf{\hat{D}}^{-1/2} \mathbf{X} \mathbf{\Theta},\]

where \(\mathbf{\hat{A}} = \mathbf{A} + \mathbf{I}\) denotes the adjacency matrix with inserted self-loops and \(\hat{D}_{ii} = \sum_{j=0} \hat{A}_{ij}\) its diagonal degree matrix.

Parameters:
  • num_features (int) – The dimension of features.
  • num_classes (int) – The number of classes.
  • device (torch.device or str) – The device where model will be running on.
  • init (bool.) – If True(False), the model will (not) be initialized.
class autogl.module.model.pyg.AutoGAT(num_features=None, num_classes=None, device=None, **args)[source]

AutoGAT. The model used in this automodel is GAT, i.e., the graph attentional network from the “Graph Attention Networks” paper. The layer is

\[\mathbf{x}^{\prime}_i = \alpha_{i,i}\mathbf{\Theta}\mathbf{x}_{i} + \sum_{j \in \mathcal{N}(i)} \alpha_{i,j}\mathbf{\Theta}\mathbf{x}_{j}\]

where the attention coefficients \(\alpha_{i,j}\) are computed as

\[\alpha_{i,j} = \frac{ \exp\left(\mathrm{LeakyReLU}\left(\mathbf{a}^{\top} [\mathbf{\Theta}\mathbf{x}_i \, \Vert \, \mathbf{\Theta}\mathbf{x}_j] \right)\right)} {\sum_{k \in \mathcal{N}(i) \cup \{ i \}} \exp\left(\mathrm{LeakyReLU}\left(\mathbf{a}^{\top} [\mathbf{\Theta}\mathbf{x}_i \, \Vert \, \mathbf{\Theta}\mathbf{x}_k] \right)\right)}.\]
Parameters:
  • num_features (int.) – The dimension of features.
  • num_classes (int.) – The number of classes.
  • device (torch.device or str) – The device where model will be running on.
  • init (bool.) – If True(False), the model will (not) be initialized.
  • args (Other parameters.) –
class autogl.module.model.pyg.AutoGIN(num_features=None, num_classes=None, device=None, init=False, num_graph_features=0, **args)[source]

AutoGIN. The model used in this automodel is GIN, i.e., the graph isomorphism network from the “How Powerful are Graph Neural Networks?” paper. The layer is

\[\mathbf{x}^{\prime}_i = h_{\mathbf{\Theta}} \left( (1 + \epsilon) \cdot \mathbf{x}_i + \sum_{j \in \mathcal{N}(i)} \mathbf{x}_j \right)\]

or

\[\mathbf{X}^{\prime} = h_{\mathbf{\Theta}} \left( \left( \mathbf{A} + (1 + \epsilon) \cdot \mathbf{I} \right) \cdot \mathbf{X} \right),\]

here \(h_{\mathbf{\Theta}}\) denotes a neural network, .i.e. an MLP.

Parameters:
  • num_features (int.) – The dimension of features.
  • num_classes (int.) – The number of classes.
  • device (torch.device or str) – The device where model will be running on.
  • init (bool.) – If True(False), the model will (not) be initialized.
class autogl.module.model.pyg.GCN4GNNGuard(nfeat, nclass, nhid, activation, dropout=0.5, lr=0.01, drop=False, weight_decay=0.0005, with_relu=True, with_bias=True, add_self_loops=True, normalize=True)[source]
fit(features, adj, labels, idx_train, idx_val=None, idx_test=None, train_iters=81, att_0=None, attention=False, model_name=None, verbose=False, normalize=False, patience=510)[source]

train the gcn model, when idx_val is not None, pick the best model according to the validation loss

forward(x, adj)[source]

we don’t change the edge_index, just update the edge_weight; some edge_weight are regarded as removed if it equals to zero

predict(features=None, adj=None)[source]

By default, inputs are unnormalized data

class autogl.module.model.pyg.GCN4GNNGuard_attack(nfeat, nclass, nhid, activation, dropout=0.5, lr=0.01, drop=False, weight_decay=0.0005, with_relu=True, with_bias=True, add_self_loops=True, normalize=True)[source]
fit(features, adj, labels, idx_train, idx_val=None, idx_test=None, train_iters=81, att_0=None, attention=False, model_name=None, initialize=True, verbose=False, normalize=False, patience=510)[source]

train the gcn model, when idx_val is not None, pick the best model according to the validation loss

forward(x, adj_lil)[source]

we don’t change the edge_index, just update the edge_weight; some edge_weight are regarded as removed if it equals to zero

predict(features=None, adj=None)[source]

By default, inputs are unnormalized data

Encoders

Decoders