morphoclass.layers.cheb_conv_separable module¶
Implementation of the ChebConvSeparable layer.
-
class
morphoclass.layers.cheb_conv_separable.ChebConvSeparable(in_channels, out_channels, orders, bias=True, flow='target_to_source', **kwargs)¶ Bases:
torch_geometric.nn.conv.message_passing.MessagePassingSeparable version of the ChebConv layer.
Two changes:
Depth-separable convolutions
Sparse specification of order parameter for polynomials (see the order parameter in __init__).
- Parameters
in_channels (int) – Size of each input sample.
out_channels (int) – Size of each output sample.
orders (int or iterable of int) – The Chebyshev filter sizes. If an integer is provided then all sizes from 0 to (K-1) will be included, otherwise only those in the iterable.
bias (bool, default True) – If set to
False, the layer will not learn an additive bias.**kwargs – Additional arguments of torch_geometric.nn.conv.MessagePassing.
-
forward(x, edge_index, edge_weight=None, batch=None, lambda_max=3.0)¶ Compute the forward pass.
- Parameters
x – The batched input node features.
edge_index – The batched input adjacency matrices.
edge_weight – The edge weights.
batch – Not used?
lambda_max (float) – The lambda_max value to use for the normalization of the graph Laplacian.
- Returns
out – The output feature maps.
- Return type
torch.Tensor
-
message(x_j, norm)¶ Perform a message passing step.
- Parameters
x_j – Node features.
norm – The edge weights (?). See documentation of pytorch-geometric for more details.
- Returns
The result of message passing.
- Return type
torch.Tensor
-
static
norm(edge_index, num_nodes, edge_weight, dtype=None, lambda_max=3.0)¶ Given the adjacency matrix calculate the normalised Laplacian.
- Parameters
edge_index – the edge indices of the adjacency matrix
num_nodes – the number of nodes in the graph, the adjacency matrix is of dimension (`num_nodes, num_nodes)
edge_weight – the entries in the adjacency matrix index by edge_index
dtype – the dtype of the adjacency matrix
lambda_max – the pre-computed maximal eigenvalue of the normalised Laplacian. Note that in the original PyG implementation this was implicitly assumed to have value 2.0.
- Returns
the sparse form of the normalised graph Laplacian
- Return type
edge_index, norm
-
reset_parameters()¶ Initialize all weights with Glorot and set all biases to zero.