GNN Models#

class fedgraph.gnn_models.AggreGCN(nfeat: int, nhid: int, nclass: int, dropout: float, NumLayers: int)[source]#

This class is an Aggregated GCN model with different methods of aggregation on the input features for the graph nodes on the first layer with a linear layer and the rest of the layers with GCNConv layers.

Parameters:
  • nfeat (int) – Number of input features.

  • nhid (int) – Number of hidden features in the hidden layers of the network.

  • nclass (int) – Number of output classes.

  • dropout (float) – Dropout probability.

  • NumLayers (int) – Number of GCN layers in the network.

forward(aggregated_feature: Tensor, adj_t: Tensor) Tensor[source]#

Represents the forward pass computation of a GCN with different methods of aggregation on the input features for the graph nodes on the first layer with a linear layer and the rest of the layers with GCNConv layers.

Parameters:
  • x (torch.Tensor) – Input feature tensor for the graph nodes aggregated by the aggregation method.

  • adj_t (torch.Tensor) – Adjacency matrix of the graph.

Returns:

(tensor) – The log softmax of the output of the last layer.

Return type:

torch.Tensor

reset_parameters() None[source]#
class fedgraph.gnn_models.GCN(nfeat: int, nhid: int, nclass: int, dropout: float, NumLayers: int)[source]#

A Graph Convolutional Network model implementation which creates a GCN with specified numbers of features, hidden layers, and output classes.

Parameters:
  • nfeat (int) – The number of input features

  • nhid (int) – The number of hidden features in each layer of the network

  • nclass (int) – The number of output classes

  • dropout (float) – The dropout probability

  • NumLayers (int) – The number of layers in the GCN

forward(x: Tensor, adj_t: Tensor) Tensor[source]#

Represents the forward pass computation of a GCN

Parameters:
  • x (torch.Tensor) – Input feature tensor for the graph nodes.

  • adj_t (torch.Tensor) – Adjacency matrix of the graph.

Returns:

(tensor)

Return type:

torch.Tensor

reset_parameters() None[source]#

Available to cater to weight initialization requirements as necessary.

class fedgraph.gnn_models.GCN_arxiv(nfeat: int, nhid: int, nclass: int, dropout: float, NumLayers: int)[source]#

A variant of the GCN model tailored for the arXiv dataset.

Parameters:
  • nfeat (int) – Number of input features.

  • nhid (int) – Number of hidden features in the hidden layers of the network.

  • nclass (int) – Number of output classes.

  • dropout (float) – Dropout probability.

  • NumLayers (int) – Number of GCN layers in the network.

forward(x: Tensor, adj_t: Tensor) Tensor[source]#

Represents the forward pass computation of a GCN

Parameters:
  • x (torch.Tensor) – Input feature tensor for the graph nodes.

  • adj_t (torch.Tensor) – Adjacency matrix of the graph.

Returns:

(tensor)

Return type:

torch.Tensor

reset_parameters() None[source]#

This function is available to cater to weight initialization requirements as necessary.

class fedgraph.gnn_models.GCN_products(nfeat: int, nhid: int, nclass: int, dropout: float, NumLayers: int)[source]#

A specialized GCN model implementation designed for product graphs.

Parameters:
  • nfeat (int) – Number of input features.

  • nhid (int) – Number of hidden features in the hidden layers of the network.

  • nclass (int) – Number of output classes.

  • dropout (float) – Dropout probability.

  • NumLayers (int) – Number of GCN layers in the network.

forward(x: Tensor, adj_t: Tensor) Tensor[source]#

This function represents the forward pass computation of a GCN with products as input features for the graph nodes on the first layer and the rest of the layers with GCNConv layers.

xtorch.Tensor

Input feature tensor for the graph nodes.

adj_ttorch.Tensor

Adjacency matrix of the graph.

Returns:

(tensor)

Return type:

torch.Tensor

reset_parameters() None[source]#

This function is available to cater to weight initialization requirements as necessary.

class fedgraph.gnn_models.SAGE_products(nfeat: int, nhid: int, nclass: int, dropout: float, NumLayers: int)[source]#

A Graph SAGE model designed specifically for handling product graphs as another variant of GCN.

Parameters:
  • nfeat (int) – Number of input features.

  • nhid (int) – Number of hidden features in the hidden layers of the network.

  • nclass (int) – Number of output classes.

  • dropout (float) – Dropout probability.

  • NumLayers (int) – Number of Graph Sage layers in the network.

forward(x: Tensor, adj_t: Tensor) Tensor[source]#

Represents the forward pass computation of a Graph Sage model

Parameters:
  • x (torch.Tensor) – Input feature tensor for the graph nodes.

  • adj_t (torch.Tensor) – Adjacency matrix of the graph.

Returns:

(tensor)

Return type:

torch.Tensor

reset_parameters() None[source]#

Available to cater to weight initialization requirements as necessary.