deeprank2.neuralnets

deeprank2.neuralnets.cnn.model3d

class deeprank2.neuralnets.cnn.model3d.CnnRegression(*args: Any, **kwargs: Any)[source]

Bases: Module

Convolutional Neural Network architecture for regression.

This type of network is used to predict a single scalar value of a continuous variable.

Parameters
  • num_features – Number of features in the input data.

  • box_shape – Shape of the input data.

forward(data)[source]
class deeprank2.neuralnets.cnn.model3d.CnnClassification(*args: Any, **kwargs: Any)[source]

Bases: Module

Convolutional Neural Network architecture for binary classification.

This type of network is used to predict the class of an input data point.

Parameters
  • num_features – Number of features in the input data.

  • box_shape – Shape of the input data.

forward(data)[source]

deeprank2.neuralnets.gnn.alignmentnet

class deeprank2.neuralnets.gnn.alignmentnet.GNNLayer(*args: Any, **kwargs: Any)[source]

Bases: Module

Custom-defined layer of a Graph Neural Network.

Parameters
  • nmb_edge_projection – Number of features in the edge projection.

  • nmb_hidden_attr – Number of features in the hidden attributes.

  • nmb_output_features – Number of output features.

  • message_vector_length – Length of the message vector.

  • nmb_mlp_neurons – Number of neurons in the MLP.

  • act_fn – Activation function. Defaults to nn.SiLU().

  • is_last_layer – Whether this is the last layer of the GNN. Defaults to True.

edge_model(edge_attr, hidden_features_source, hidden_features_target)[source]
node_model(summed_edge_message, hidden_features)[source]
sum_messages(edges, messages, nmb_nodes)[source]
update_nodes(edges, edge_attr, hidden_features, steps=1)[source]
output(hidden_features, get_attention=True)[source]
class deeprank2.neuralnets.gnn.alignmentnet.SuperGNN(*args: Any, **kwargs: Any)[source]

Bases: Module

SuperGNN is a class that defines multiple GNN layers.

In particular, the preproc_edge_mlp and preproc_node_mlp are meant to preprocess the edge and node attributes, respectively.

The modlist is a list of GNNLayer objects.

Parameters
  • nm_edge_attr – Number of edge features.

  • nmb_node_attr – Number of node features.

  • nmb_hidden_attr – Number of hidden features.

  • nmb_mlp_neurons – Number of neurons in the MLP.

  • nmb_edge_projection – Number of edge projections.

  • nmb_gnn_layers – Number of GNN layers.

  • nmb_output_features – Number of output features.

  • message_vector_length – Length of the message vector.

  • act_fn – Activation function. Defaults to nn.SiLU().

preprocess(edge_attr, node_attr)[source]
run_through_network(edges, edge_attr, node_attr, with_output_attention=False)[source]
class deeprank2.neuralnets.gnn.alignmentnet.AlignmentGNN(*args: Any, **kwargs: Any)[source]

Bases: SuperGNN

Architecture based on multiple GNNLayer layers, suited for both regression and classification tasks.

It applies different layers to the nodes and edges of a graph (preproc_edge_mlp and preproc_node_mlp), and then applies multiple GNN layers (modlist).

Parameters
  • nm_edge_attr – Number of edge features.

  • nmb_node_attr – Number of node features.

  • nmb_output_features – Number of output features.

  • nmb_hidden_attr – Number of hidden features.

  • message_vector_length – Length of the message vector.

  • nmb_mlp_neurons – Number of neurons in the MLP.

  • nmb_gnn_layers – Number of GNN layers.

  • nmb_edge_projection – Number of edge projections.

  • act_fn – Activation function. Defaults to nn.SiLU().

forward(edges, edge_attr, node_attr)[source]
preprocess(edge_attr, node_attr)
run_through_network(edges, edge_attr, node_attr, with_output_attention=False)

deeprank2.neuralnets.gnn.foutnet

class deeprank2.neuralnets.gnn.foutnet.FoutLayer(*args: Any, **kwargs: Any)[source]

Bases: Module

FoutLayer.

This layer is described by eq. (1) of Protein Interface Predition using Graph Convolutional Network by Alex Fout et al. NIPS 2018.

Parameters
  • in_channels – Size of each input sample.

  • out_channels – Size of each output sample.

  • bias – If set to False, the layer will not learn an additive bias. Defaults to True.

reset_parameters() None[source]
forward(x, edge_index)[source]
class deeprank2.neuralnets.gnn.foutnet.FoutNet(*args: Any, **kwargs: Any)[source]

Bases: Module

Architecture based on the FoutLayer, suited for both regression and classification tasks.

It also uses community pooling to reduce the number of nodes.

Parameters
  • input_shape – Size of each input sample.

  • output_shape – Size of each output sample. Defaults to 1.

  • input_shape_edge – Size of each input edge. Defaults to None.

forward(data)[source]

deeprank2.neuralnets.gnn.ginet

class deeprank2.neuralnets.gnn.ginet.GINetConvLayer(*args: Any, **kwargs: Any)[source]

Bases: Module

GiNet convolutional layer for graph neural networks.

Parameters
  • in_channels – Number of input features.

  • out_channels – Number of output features.

  • number_edge_features – Number of edge features. Defaults to 1.

  • bias – If set to False, the layer will not learn an additive bias. Defaults to False.

reset_parameters() None[source]
forward(x, edge_index, edge_attr)[source]
class deeprank2.neuralnets.gnn.ginet.GINet(*args: Any, **kwargs: Any)[source]

Bases: Module

Architecture based on the GiNet convolutional layer, suited for both regression and classification tasks.

It uses community pooling to reduce the number of nodes.

Parameters
  • input_shape – Number of input features.

  • output_shape – Number of output value per graph. Defaults to 1.

  • input_shape_edge – Number of edge input features. Defaults to 1.

forward(data)[source]

deeprank2.neuralnets.gnn.ginet_nocluster

class deeprank2.neuralnets.gnn.ginet_nocluster.GINetConvLayer(*args: Any, **kwargs: Any)[source]

Bases: Module

GiNet convolutional layer for graph neural networks.

Parameters
  • in_channels – Number of input features.

  • out_channels – Number of output features.

  • number_edge_features – Number of edge features. Defaults to 1.

  • bias – If set to False, the layer will not learn an additive bias. Defaults to False.

reset_parameters() None[source]
forward(x, edge_index, edge_attr)[source]
class deeprank2.neuralnets.gnn.ginet_nocluster.GINet(*args: Any, **kwargs: Any)[source]

Bases: Module

Architecture based on the GiNet convolutional layer, suited for both regression and classification tasks.

Parameters
  • input_shape – Number of input features.

  • output_shape – Number of output value per graph. Defaults to 1.

  • input_shape_edge – Number of edge input features. Defaults to 1.

forward(data)[source]

deeprank2.neuralnets.gnn.vanilla_gnn

class deeprank2.neuralnets.gnn.vanilla_gnn.VanillaConvolutionalLayer(*args: Any, **kwargs: Any)[source]

Bases: Module

Vanilla convolutional layer for graph neural networks.

Parameters
  • count_node_features – Number of node features.

  • count_edge_features – Number of edge features.

forward(node_features, edge_node_indices, edge_features)[source]
class deeprank2.neuralnets.gnn.vanilla_gnn.VanillaNetwork(*args: Any, **kwargs: Any)[source]

Bases: Module

Vanilla graph neural network architecture suited for both regression and classification tasks.

It uses two vanilla convolutional layers and a MLP to predict the output.

Parameters
  • input_shape – Number of node input features.

  • output_shape – Number of output value per graph.

  • input_shape_edge – Number of edge input features.

forward(data)[source]

deeprank2.neuralnets.gnn.sgat

class deeprank2.neuralnets.gnn.sgat.SGraphAttentionLayer(*args: Any, **kwargs: Any)[source]

Bases: Module

SGraphAttentionLayer.

This is a new layer that is similar to the graph attention network but simpler z_i = 1 / Ni Sum_j a_ij * [x_i || x_j] * W + b_i || is the concatenation operator: [1,2,3] || [4,5,6] = [1,2,3,4,5,6] Ni is the number of neighbor of node i Sum_j runs over the neighbors of node i a_ij is the edge attribute between node i and j

Parameters
  • in_channels – Size of each input sample.

  • out_channels – Size of each output sample.

  • bias – If set to False, the layer will not learn an additive bias. Defaults to True.

reset_parameters() None[source]
forward(x, edge_index, edge_attr)[source]
class deeprank2.neuralnets.gnn.sgat.SGAT(*args: Any, **kwargs: Any)[source]

Bases: Module

Simple graph attention network, suited for both regression and classification tasks.

It uses two graph attention layers and a MLP to predict the output.

Parameters
  • input_shape – Size of each input sample.

  • output_shape – Size of each output sample. Defaults to 1.

  • input_shape_edge – Size of each input edge. Defaults to None.

forward(data)[source]