GOOD.networks.models.GINs

The Graph Neural Network from the “How Powerful are Graph Neural Networks?” paper.

Classes

GIN(config)

The Graph Neural Network from the "How Powerful are Graph Neural Networks?" paper.

GINEConv(nn[, eps, train_eps, edge_dim])

The modified GINConv operator from the "Strategies for Pre-training Graph Neural Networks" paper

GINEncoder(config, *args, **kwargs)

The GIN encoder for non-molecule data, using the GINConv operator for message passing.

GINFeatExtractor(config, **kwargs)

GIN feature extractor using the GINEncoder or GINMolEncoder.

GINMolEncoder(config, **kwargs)

The GIN encoder for molecule data, using the GINEConv operator for message passing.

class GOOD.networks.models.GINs.GIN(config: Union[CommonArgs, Munch])[source]

Bases: GNNBasic

The Graph Neural Network from the “How Powerful are Graph Neural Networks?” paper.

Parameters

config (Union[CommonArgs, Munch]) – munchified dictionary of args (config.model.dim_hidden, config.model.model_layer, config.dataset.dim_node, config.dataset.num_classes, config.dataset.dataset_type)

forward(*args, **kwargs) Tensor[source]

The GIN model implementation.

Parameters
  • *args (list) – argument list for the use of arguments_read. Refer to arguments_read

  • **kwargs (dict) – key word arguments for the use of arguments_read. Refer to arguments_read

Returns (Tensor):

label predictions

class GOOD.networks.models.GINs.GINEConv(nn: Callable, eps: float = 0.0, train_eps: bool = False, edge_dim: Optional[int] = None, **kwargs)[source]

Bases: MessagePassing

The modified GINConv operator from the “Strategies for Pre-training Graph Neural Networks” paper

\[\mathbf{x}^{\prime}_i = h_{\mathbf{\Theta}} \left( (1 + \epsilon) \cdot \mathbf{x}_i + \sum_{j \in \mathcal{N}(i)} \mathrm{ReLU} ( \mathbf{x}_j + \mathbf{e}_{j,i} ) \right)\]

that is able to incorporate edge features \(\mathbf{e}_{j,i}\) into the aggregation procedure.

Parameters
  • nn (torch.nn.Module) – A neural network \(h_{\mathbf{\Theta}}\) that maps node features x of shape [-1, in_channels] to shape [-1, out_channels], e.g., defined by torch.nn.Sequential.

  • eps (float, optional) – (Initial) \(\epsilon\)-value. (default: 0.)

  • train_eps (bool, optional) – If set to True, \(\epsilon\) will be a trainable parameter. (default: False)

  • edge_dim (int, optional) – Edge feature dimensionality. If set to None, node and edge feature dimensionality is expected to match. Other-wise, edge features are linearly transformed to match node feature dimensionality. (default: None)

  • **kwargs (optional) – Additional arguments of torch_geometric.nn.conv.MessagePassing.

Shapes:
  • input: node features \((|\mathcal{V}|, F_{in})\) or \(((|\mathcal{V_s}|, F_{s}), (|\mathcal{V_t}|, F_{t}))\) if bipartite, edge indices \((2, |\mathcal{E}|)\), edge features \((|\mathcal{E}|, D)\) (optional)

  • output: node features \((|\mathcal{V}|, F_{out})\) or \((|\mathcal{V}_t|, F_{out})\) if bipartite

message(x_j: Tensor, edge_attr: Tensor) Tensor[source]

Constructs messages from node \(j\) to node \(i\) in analogy to \(\phi_{\mathbf{\Theta}}\) for each edge in edge_index. This function can take any argument as input which was initially passed to propagate(). Furthermore, tensors passed to propagate() can be mapped to the respective nodes \(i\) and \(j\) by appending _i or _j to the variable name, .e.g. x_i and x_j.

class GOOD.networks.models.GINs.GINEncoder(config: Union[CommonArgs, Munch], *args, **kwargs)[source]

Bases: BasicEncoder

The GIN encoder for non-molecule data, using the GINConv operator for message passing.

Parameters

config (Union[CommonArgs, Munch]) – munchified dictionary of args (config.model.dim_hidden, config.model.model_layer, config.dataset.dim_node)

forward(x, edge_index, batch, batch_size, **kwargs)[source]

The GIN encoder for non-molecule data.

Parameters
  • x (Tensor) – node features

  • edge_index (Tensor) – edge indices

  • batch (Tensor) – batch indicator

  • batch_size (int) – batch size

Returns (Tensor):

node feature representations

class GOOD.networks.models.GINs.GINFeatExtractor(config: Union[CommonArgs, Munch], **kwargs)[source]

Bases: GNNBasic

GIN feature extractor using the GINEncoder or GINMolEncoder.

Parameters

config (Union[CommonArgs, Munch]) – munchified dictionary of args (config.model.dim_hidden, config.model.model_layer, config.dataset.dim_node, config.dataset.dataset_type)

forward(*args, **kwargs)[source]

GIN feature extractor using the GINEncoder or GINMolEncoder.

Parameters
  • *args (list) – argument list for the use of arguments_read. Refer to arguments_read

  • **kwargs (dict) – key word arguments for the use of arguments_read. Refer to arguments_read

Returns (Tensor):

node feature representations

class GOOD.networks.models.GINs.GINMolEncoder(config: Union[CommonArgs, Munch], **kwargs)[source]

Bases: BasicEncoder

The GIN encoder for molecule data, using the GINEConv operator for message passing.

Parameters

config (Union[CommonArgs, Munch]) – munchified dictionary of args (config.model.dim_hidden, config.model.model_layer)

forward(x, edge_index, edge_attr, batch, batch_size, **kwargs)[source]

The GIN encoder for molecule data.

Parameters
  • x (Tensor) – node features

  • edge_index (Tensor) – edge indices

  • edge_attr (Tensor) – edge attributes

  • batch (Tensor) – batch indicator

  • batch_size (int) – Batch size.

Returns (Tensor):

node feature representations