GOOD.networks.models.Pooling
The pooling classes for the use of the GNNs.
Classes
|
Base pooling class. |
Global add pooling |
|
Global max pooling |
|
Global mean pooling |
|
Identical pooling |
- 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.