topobench.nn.backbones.simplicial package#
Submodules#
topobench.nn.backbones.simplicial.sccnn module#
Implementation of the Simplicial Complex Convolutional Neural Network (SCCNN) for complex classification.
- class topobench.nn.backbones.simplicial.sccnn.SCCNNCustom(in_channels_all, hidden_channels_all, conv_order, sc_order, aggr_norm=False, update_func=None, n_layers=2)[source]#
Bases:
Module
SCCNN implementation for complex classification.
Note: In this task, we can consider the output on any order of simplices for the classification task, which of course can be amended by a readout layer.
- Parameters:
- in_channels_alltuple of int
Dimension of input features on (nodes, edges, faces).
- hidden_channels_alltuple of int
Dimension of features of hidden layers on (nodes, edges, faces).
- conv_orderint
Order of convolutions, we consider the same order for all convolutions.
- sc_orderint
Order of simplicial complex.
- aggr_normbool, optional
Whether to normalize the aggregation (default: False).
- update_funcstr, optional
Update function for the simplicial complex convolution (default: None).
- n_layersint, optional
Number of layers (default: 2).
- forward(x_all, laplacian_all, incidence_all)[source]#
Forward computation.
- Parameters:
- x_alltuple(tensors)
Tuple of feature tensors (node, edge, face).
- laplacian_alltuple(tensors)
Tuple of Laplacian tensors (graph laplacian L0, down edge laplacian L1_d, upper edge laplacian L1_u, face laplacian L2).
- incidence_alltuple(tensors)
Tuple of order 1 and 2 incidence matrices.
- Returns:
- tuple(tensors)
Tuple of final hidden state tensors (node, edge, face).
- class topobench.nn.backbones.simplicial.sccnn.SCCNNLayer(in_channels, out_channels, conv_order, sc_order, aggr_norm: bool = False, update_func=None, initialization: str = 'xavier_normal')[source]#
Bases:
Module
Layer of a Simplicial Complex Convolutional Neural Network.
- Parameters:
- in_channelstuple of int
Dimensions of input features on nodes, edges, and faces.
- out_channelstuple of int
Dimensions of output features on nodes, edges, and faces.
- conv_orderint
Convolution order of the simplicial filters.
- sc_orderint
SC order.
- aggr_normbool, optional
Whether to normalize the aggregated message by the neighborhood size (default: False).
- update_funcstr, optional
Activation function used in aggregation layers (default: None).
- initializationstr, optional
Initialization method for the weights (default: “xavier_normal”).
- aggr_norm_func(conv_operator, x)[source]#
Perform aggregation normalization.
- Parameters:
- conv_operatortorch.sparse
Convolution operator.
- xtorch.Tensor
Feature tensor.
- Returns:
- torch.Tensor
Normalized feature tensor.
- chebyshev_conv(conv_operator, conv_order, x)[source]#
Perform Chebyshev convolution.
- Parameters:
- conv_operatortorch.sparse
Convolution operator.
- conv_orderint
Order of the convolution.
- xtorch.Tensor
Feature tensor.
- Returns:
- torch.Tensor
Output tensor.
- forward(x_all, laplacian_all, incidence_all)[source]#
Forward computation.
- Parameters:
- x_alltuple of tensors
Tuple of input feature tensors (node, edge, face).
- laplacian_alltuple of tensors
Tuple of Laplacian tensors (graph laplacian L0, down edge laplacian L1_d, upper edge laplacian L1_u, face laplacian L2).
- incidence_alltuple of tensors
Tuple of order 1 and 2 incidence matrices.
- Returns:
- torch.Tensor
Output tensor for each 0-cell.
- torch.Tensor
Output tensor for each 1-cell.
- torch.Tensor
Output tensor for each 2-cell.
Module contents#
Simplicial backbones with automated exports.
- class topobench.nn.backbones.simplicial.SCCNNCustom(in_channels_all, hidden_channels_all, conv_order, sc_order, aggr_norm=False, update_func=None, n_layers=2)#
Bases:
Module
SCCNN implementation for complex classification.
Note: In this task, we can consider the output on any order of simplices for the classification task, which of course can be amended by a readout layer.
- Parameters:
- in_channels_alltuple of int
Dimension of input features on (nodes, edges, faces).
- hidden_channels_alltuple of int
Dimension of features of hidden layers on (nodes, edges, faces).
- conv_orderint
Order of convolutions, we consider the same order for all convolutions.
- sc_orderint
Order of simplicial complex.
- aggr_normbool, optional
Whether to normalize the aggregation (default: False).
- update_funcstr, optional
Update function for the simplicial complex convolution (default: None).
- n_layersint, optional
Number of layers (default: 2).
- forward(x_all, laplacian_all, incidence_all)#
Forward computation.
- Parameters:
- x_alltuple(tensors)
Tuple of feature tensors (node, edge, face).
- laplacian_alltuple(tensors)
Tuple of Laplacian tensors (graph laplacian L0, down edge laplacian L1_d, upper edge laplacian L1_u, face laplacian L2).
- incidence_alltuple(tensors)
Tuple of order 1 and 2 incidence matrices.
- Returns:
- tuple(tensors)
Tuple of final hidden state tensors (node, edge, face).
- class topobench.nn.backbones.simplicial.SCCNNLayer(in_channels, out_channels, conv_order, sc_order, aggr_norm: bool = False, update_func=None, initialization: str = 'xavier_normal')#
Bases:
Module
Layer of a Simplicial Complex Convolutional Neural Network.
- Parameters:
- in_channelstuple of int
Dimensions of input features on nodes, edges, and faces.
- out_channelstuple of int
Dimensions of output features on nodes, edges, and faces.
- conv_orderint
Convolution order of the simplicial filters.
- sc_orderint
SC order.
- aggr_normbool, optional
Whether to normalize the aggregated message by the neighborhood size (default: False).
- update_funcstr, optional
Activation function used in aggregation layers (default: None).
- initializationstr, optional
Initialization method for the weights (default: “xavier_normal”).
- aggr_norm_func(conv_operator, x)#
Perform aggregation normalization.
- Parameters:
- conv_operatortorch.sparse
Convolution operator.
- xtorch.Tensor
Feature tensor.
- Returns:
- torch.Tensor
Normalized feature tensor.
- chebyshev_conv(conv_operator, conv_order, x)#
Perform Chebyshev convolution.
- Parameters:
- conv_operatortorch.sparse
Convolution operator.
- conv_orderint
Order of the convolution.
- xtorch.Tensor
Feature tensor.
- Returns:
- torch.Tensor
Output tensor.
- forward(x_all, laplacian_all, incidence_all)#
Forward computation.
- Parameters:
- x_alltuple of tensors
Tuple of input feature tensors (node, edge, face).
- laplacian_alltuple of tensors
Tuple of Laplacian tensors (graph laplacian L0, down edge laplacian L1_d, upper edge laplacian L1_u, face laplacian L2).
- incidence_alltuple of tensors
Tuple of order 1 and 2 incidence matrices.
- Returns:
- torch.Tensor
Output tensor for each 0-cell.
- torch.Tensor
Output tensor for each 1-cell.
- torch.Tensor
Output tensor for each 2-cell.
- reset_parameters(gain: float = 1.414)#
Reset learnable parameters.
- Parameters:
- gainfloat
Gain for the weight initialization.
- update(x)#
Update embeddings on each cell (step 4).
- Parameters:
- xtorch.Tensor
Input tensor.
- Returns:
- torch.Tensor
Updated tensor.