MCPcopy
hub / github.com/THUDM/CogDL / batch_sum_pooling

Function batch_sum_pooling

docs/source/tutorial_cn/examples/1graph_cn.py:46–56  ·  view source on GitHub ↗
(x, batch)

Source from the content-addressed store, hash-verified

44# 如何进行全局池化对每个图中节点的特征进行求和
45# --------------------------------------------------------------------------------------------------------
46def batch_sum_pooling(x, batch):
47 batch_size = int(torch.max(batch.cpu())) + 1
48 res = torch.zeros(batch_size, x.size(1)).to(x.device)
49 out = res.scatter_add_(
50 dim=0,
51 index=batch.unsqueeze(-1).expand_as(x),
52 src=x
53 )
54 return out
55
56 return out
57
58# %%
59# 如何编辑一个graph?

Callers

nothing calls this directly

Calls 1

toMethod · 0.45

Tested by

no test coverage detected