question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sample doesn't work correctly when nodes are repeated in input

See original GitHub issue

https://github.com/rusty1s/pytorch_sparse/blob/3ec1eacf1c1cbf22c2fc95cff6ddd1ccc5d2efa6/csrc/cpu/neighbor_sample_cpu.cpp#L108

Working on https://github.com/pyg-team/pytorch_geometric/issues/4026 I discovered that this sampling function does not work properly when the input_node array has duplicates. In this case the number of samples can be > number of edges and the index i doesn’t do what you’d expect it to.

Another strange behaviour is when using the function as

torch.ops.torch_sparse.neighbor_sample(
            torch.Tensor([0, 1, 2, 3]).type(torch.long),
            torch.Tensor([1, 0, 1]).type(torch.long),
            torch.Tensor([0, 2]).type(torch.long),
            [1],
            False,
            False,
        )

The returned values are

(tensor([0, 2, 1]), tensor([2, 2, 0]), tensor([0, 1, 2]), tensor([0, 2, 1]))

but the (row, col) combination (2, 0) and (0, 2) don’t make sense, they’re not part of the original adjacency matrix.

I’m happy to dive in a bit deeper and figure out a fix (for at least the first issue, the second issue I am not sure if its actually a problem or not yet), but thought I’d check first if this is known or maybe my understanding is incorrect.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
Padarncommented, Mar 14, 2022

ohh I see, the row/col are relative to the nodes in the output? If so, then agreed.

And if this is the case… then actually the first issue is also a non-issue. Sorry for the false alarm!

0reactions
Padarncommented, Mar 20, 2022

Closing this one as we’ve agreed not to do anything about it in pytorch_sparse, thanks @rusty1s

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problems when developing message flows with file nodes - IBM
Solution: If the input messages have unique keys, modify your flow to ignore duplicate records. If the messages do not have unique keys...
Read more >
XPath contains(text(),'some string') doesn't work when used ...
An argument is converted to type string as if by calling the string function. string() function returns string-value of the first node: A...
Read more >
Top 10 Most Common Node.js Developer Mistakes - Toptal
For brevity, we used simpler examples here, but reality is often worse. Mistake #4: Expecting Callbacks to Run Synchronously. Asynchronous programming with ...
Read more >
Connect nodes at same level - GeeksforGeeks
Given a Binary Tree, The task is to connect all the adjacent nodes at the same level starting from the left-most node of...
Read more >
Using the Node-Red Function Node- Beginners Guide
The function node is used to run JavaScript code. The function node accepts a msg object as input and can return 0 or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found