Skip to content
DeepForgeby svx
All problems
EasyGraph Algorithmsgraph-182

Graph Pooling Sum

Problem

Aggregate all node feature vectors of a graph with sum pooling.

features is a list of equal-length vectors. Return the elementwise sum, or an empty list when there are no nodes.

Hint

Sum pooling is permutation invariant, a key property of graph readouts.

Test cases

case 1
in: [[[1,2],[3,4]]]
expected: [4,6]
case 2
in: [[[1,1]]]
expected: [1,1]
case 3
in: [[]]
expected: []
case 4
in: [[[1,2],[3,4],[5,6]]]
expected: [9,12]
Starter codePython
def graph_pooling_sum(features):
    # Your code here
    pass

4 test cases · run your code against them in the editor