Encoders#

Abstract class for feature encoders.

class topobenchmarkx.nn.encoders.base.AbstractFeatureEncoder[source]#

Abstract class to define a custom feature encoder.

abstract forward(data: Data) Data[source]#

Forward pass of the feature encoder model.

Parameters:
datatorch_geometric.data.Data

Input data object which should contain x features.

Class to apply BaseEncoder to the features of higher order structures.

class topobenchmarkx.nn.encoders.all_cell_encoder.AllCellFeatureEncoder(in_channels, out_channels, proj_dropout=0, selected_dimensions=None, **kwargs)[source]#

Encoder class to apply BaseEncoder.

The BaseEncoder is applied to the features of higher order structures. The class creates a BaseEncoder for each dimension specified in selected_dimensions. Then during the forward pass, the BaseEncoders are applied to the features of the corresponding dimensions.

Parameters:
in_channelslist[int]

Input dimensions for the features.

out_channelslist[int]

Output dimensions for the features.

proj_dropoutfloat, optional

Dropout for the BaseEncoders (default: 0).

selected_dimensionslist[int], optional

List of indexes to apply the BaseEncoders to (default: None).

**kwargsdict, optional

Additional keyword arguments.

forward(data: Data) Data[source]#

Forward pass.

The method applies the BaseEncoders to the features of the selected_dimensions.

Parameters:
datatorch_geometric.data.Data

Input data object which should contain x_{i} features for each i in the selected_dimensions.

Returns:
torch_geometric.data.Data

Output data object with updated x_{i} features.

class topobenchmarkx.nn.encoders.all_cell_encoder.BaseEncoder(in_channels, out_channels, dropout=0)[source]#

Base encoder class used by AllCellFeatureEncoder.

This class uses two linear layers with GraphNorm, Relu activation function, and dropout between the two layers.

Parameters:
in_channelsint

Dimension of input features.

out_channelsint

Dimensions of output features.

dropoutfloat, optional

Percentage of channels to discard between the two linear layers (default: 0).

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

Forward pass of the encoder.

It applies two linear layers with GraphNorm, Relu activation function, and dropout between the two layers.

Parameters:
xtorch.Tensor

Input tensor of dimensions [N, in_channels].

batchtorch.Tensor

The batch vector which assigns each element to a specific example.

Returns:
torch.Tensor

Output tensor of shape [N, out_channels].