Skip to content

About ptr in batches #3961

Answered by rusty1s
Nokimann asked this question in Q&A
Jan 27, 2022 · 2 comments · 4 replies
Discussion options

You must be logged in to vote

We recently also added support in torch_scatter for segment reductions, i.e., reductions in which the indices are ordered and grouped together. As such, one alternative to implement global pooling layers can be achieved via:

from torch_scatter import segment_csr

out = segment_csr(x, data.ptr, reduce='mean')

which is equivalent to doing:

out = global_mean_pool(x, data.batch)

The main advantage is that segment_csr is deterministic, i.e., no atomic operations are used.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@Nokimann
Comment options

@rusty1s
Comment options

Answer selected by Nokimann
Comment options

You must be logged in to vote
2 replies
@rusty1s
Comment options

@Nokimann
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants