Pytorch_geometric: scatter_order

Created on 23 Feb 2019  路  6Comments  路  Source: rusty1s/pytorch_geometric

How about adding something like scatter_order

Most helpful comment

row, col = edge_index
x = to_dense_batch(x, row, fill_value=1e8)
x = x.sort(dim=1)[0]
x = x.view(-1, channels)[x != fill_value]

This should work, however, it is not very efficient :(

All 6 comments

You mean scatter_sort?

Sometimes, we may want to order the neighbours of the node, according to some relationship score. It maybe useful, if we can order the neighbours. Now, we only have the scatter_max.

Ok, I understand. We do not have a dedicated CUDA kernel for this.
In the meantime I suggest you use to_dense_batch, sort the neighbors, and convert it back to a sparse layout.

how can I convert it back? Thanks

row, col = edge_index
x = to_dense_batch(x, row, fill_value=1e8)
x = x.sort(dim=1)[0]
x = x.view(-1, channels)[x != fill_value]

This should work, however, it is not very efficient :(

cool, many thanks. you are awsome

Was this page helpful?
0 / 5 - 0 ratings