Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added node_shuffle #429

Closed
wants to merge 2 commits into from
Closed

Conversation

rbSparky
Copy link
Contributor

Continues Issue #412

DGL function

Wasn't sure what to test in this one. Please let me know what other tests I should add since this is pretty straightforward.

@rbSparky rbSparky changed the title Added node shuffle Added node_shuffle Mar 19, 2024
# Returns
- `g::GNNGraph`: The GNNGraph with shuffled node features.
"""
function node_shuffle(g::GNNGraph{<:COO_T})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is mutating, so it should be called node_shuffle!

- `g::GNNGraph`: The GNNGraph with shuffled node features.
"""
function node_shuffle(g::GNNGraph{<:COO_T})
features = g.ndata.x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can have no guarantess that there exists features named x

"""
function node_shuffle(g::GNNGraph{<:COO_T})
features = g.ndata.x
num_nodes = size(features, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the node dimension is the second one

num_nodes = size(features, 1)

shuffled_indices = randperm(num_nodes)
shuffled_features = features[shuffled_indices, :]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is shuffling feature dimensions, not nodes

@CarloLucibello
Copy link
Member

Besides the issues that I commented, I think that this function should not be part of the library. It is not a common operation, it has used in that paper for probing the relevance of node features. This kind of operations should be done on the user side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants