topobench.nn.encoders package#

Init file for encoder module with automated encoder discovery.

class AllCellFeatureEncoder(in_channels, out_channels, proj_dropout=0, selected_dimensions=None, **kwargs)#

Bases: AbstractFeatureEncoder

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.

__init__(in_channels, out_channels, proj_dropout=0, selected_dimensions=None, **kwargs)#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(data)#

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 DGMStructureFeatureEncoder(in_channels, out_channels, proj_dropout=0, selected_dimensions=None, **kwargs)#

Bases: AbstractFeatureEncoder

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.

__init__(in_channels, out_channels, proj_dropout=0, selected_dimensions=None, **kwargs)#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(data)#

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 FlatEncoder(in_channels, out_channels, **kwargs)#

Bases: AbstractFeatureEncoder

Abstract class to define a custom feature encoder.

Parameters:
in_channelsint

Number of input channels.

out_channelsint

Number of output channels.

**kwargs

Additional keyword arguments.

__init__(in_channels, out_channels, **kwargs)#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(data)#

Forward pass of the flat encoder.

Parameters:
datatorch_geometric.data.Data

Input data object which should contain x features.

Returns:
torch_geometric.data.Data

Output data object with flattened features.

class HOPSEFeatureEncoder(in_channels, out_channels, proj_dropout=0, selected_dimensions=None, max_hop=3, batch_norm=False, use_atom_encoder=False, use_bond_encoder=False, fuse_pse2cell=False, **kwargs)#

Bases: AbstractFeatureEncoder

Encoder class to apply SimpleEncoder.

The SimpleEncoder is applied to the features of each cell according to a simple

Parameters:
in_channelslist[list[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).

max_hoplist[int], optional

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

batch_normbool, optional

Wether to apply batch normalizaiton when encoding (default: False).

use_atom_encoderbool, optional

If True, replace the encoder for dimension 0 / hop 0 with an OGB AtomEncoder (default: False).

use_bond_encoderbool, optional

If True, replace the encoder for dimension 1 / hop 0 with an OGB BondEncoder (default: False).

fuse_pse2cellbool, optional

If True, concatenate and linearly project per-hop PSE encodings back into the cell features after encoding (default: False).

**kwargsdict, optional

Additional keyword arguments.

__init__(in_channels, out_channels, proj_dropout=0, selected_dimensions=None, max_hop=3, batch_norm=False, use_atom_encoder=False, use_bond_encoder=False, fuse_pse2cell=False, **kwargs)#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(data)#

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.

Submodules#