How to interpret the global max pooling operation in graph neural networks? I'm trying to use pytorch geometric for building graph convolutional networks. And I'm trying to interpret the result of the max pooling operation, which is described in this link:
https://pytorch-geometric.readthedocs.io/en/latest/modules/nn.html#torch_geometric.nn.pool.global_max_pool
If I understood it correctly, the result is a feature vector r_i (which the dimensionality of the features of the nodes in the graph), which represents the maximum, considering the feature vectors of all nodes in the graph.
But for me, it is obscure how the feature vectors are compared in order to find the vector that represents the maximum.
Can you help me?
Best regards.

Given a graph with N nodes, F features and a feature matrix X (N rows, F columns), global max pooling pools this graph into a single node in just one step. To compute the feature vector of this pooled node, it takes the feature-wise maximum across the node dimension of the graph. In other words, global max pooling finds for each feature/column in X the node with the highest value and then takes this value into the pooled node vector.
So if the feature matrix has 10 features/columns, then the vector output of the global max pooling will have length 10 and each entry will be the highest value found in the corresponding column of the feature matrix.
Here a short example:
import torch
from torch_geometric.nn import global_max_pool

tensor = torch.tensor([[1,1,3], 
                       [2,2,2],
                       [3,2,5],
                       [0,1,7],
                       [2,9,5], 
                       [1,2,6]])

batch = torch.tensor([0,0,0,0,0,0]) #all nodes are part of the same graph
global_max_pool(tensor, batch)

output = tensor([[3, 9, 7]])

and if there are several graphs in a feature matrix (batch = [0,0,1,1,2,2,]), then only the nodes that belong to the same graph are pooled:
import torch
from torch_geometric.nn import global_max_pool

tensor = torch.tensor([[1,1,3], 
                       [2,2,2],
                       [3,2,5],
                       [0,1,7],
                       [2,9,5], 
                       [1,2,6]])

batch = torch.tensor([0,0,1,1,2,2])

global_max_pool(tensor, batch)

output = tensor([[2, 2, 3],
                 [3, 2, 7],
                 [2, 9, 6]])

