GOOD.networks.models.Pooling

The pooling classes for the use of the GNNs.

Classes

GNNPool()

Base pooling class.

GlobalAddPool()

Global add pooling

GlobalMaxPool()

Global max pooling

GlobalMeanPool()

Global mean pooling

IdenticalPool()

Identical pooling

class GOOD.networks.models.Pooling.GNNPool[source]

Bases: Module

Base pooling class.

class GOOD.networks.models.Pooling.GlobalAddPool[source]

Bases: GNNPool

Global add pooling

forward(x, batch, batch_size)[source]

Returns batch-wise graph-level-outputs by adding node features across the node dimension, so that for a single graph \(\mathcal{G}_i\) its output is computed by

\[\mathbf{r}_i = \sum_{n=1}^{N_i} \mathbf{x}_n\]
Parameters
  • x (Tensor) – Node feature matrix \(\mathbf{X} \in \mathbb{R}^{(N_1 + \ldots + N_B) \times F}\).

  • batch (Tensor) – Batch vector \(\mathbf{b} \in {\{ 0, \ldots, B-1\}}^N\), which assigns each node to a specific example.

  • batch_size (int) – Batch size.

Returns (Tensor):

batch-wise graph-level-outputs by adding node features across the node dimension.

class GOOD.networks.models.Pooling.GlobalMaxPool[source]

Bases: GNNPool

Global max pooling

forward(x, batch, batch_size)[source]

Returns batch-wise graph-level-outputs by taking the channel-wise maximum across the node dimension, so that for a single graph \(\mathcal{G}_i\) its output is computed by

\[\mathbf{r}_i = \mathrm{max}_{n=1}^{N_i} \, \mathbf{x}_n\]
Parameters
  • x (Tensor) – Node feature matrix \(\mathbf{X} \in \mathbb{R}^{(N_1 + \ldots + N_B) \times F}\).

  • batch (Tensor) – Batch vector \(\mathbf{b} \in {\{ 0, \ldots, B-1\}}^N\), which assigns each node to a specific example.

  • batch_size (int) – Batch size.

Returns (Tensor):

batch-wise graph-level-outputs by taking the channel-wise maximum across the node dimension.

class GOOD.networks.models.Pooling.GlobalMeanPool[source]

Bases: GNNPool

Global mean pooling

forward(x, batch, batch_size)[source]

Returns batch-wise graph-level-outputs by averaging node features across the node dimension, so that for a single graph \(\mathcal{G}_i\) its output is computed by

\[\mathbf{r}_i = \frac{1}{N_i} \sum_{n=1}^{N_i} \mathbf{x}_n\]
Parameters
  • x (Tensor) – Node feature matrix \(\mathbf{X} \in \mathbb{R}^{(N_1 + \ldots + N_B) \times F}\).

  • batch (Tensor) – Batch vector \(\mathbf{b} \in {\{ 0, \ldots, B-1\}}^N\), which assigns each node to a specific example.

  • batch_size (int) – Batch size.

Returns (Tensor):

batch-wise graph-level-outputs by averaging node features across the node dimension.

class GOOD.networks.models.Pooling.IdenticalPool[source]

Bases: GNNPool

Identical pooling

forward(x, batch)[source]

Returns batch-wise graph-level-outputs by taking the node features identically.

Parameters
  • x (Tensor) – Node feature matrix

  • batch (Tensor) – Batch vector

Returns (Tensor):

batch-wise graph-level-outputs by taking the node features identically.