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

[Feature] Max readout and consecutive labeling for networkx #341

Merged
merged 19 commits into from
Jan 10, 2019
Merged

[Feature] Max readout and consecutive labeling for networkx #341

merged 19 commits into from
Jan 10, 2019

Conversation

mufeili
Copy link
Member

@mufeili mufeili commented Jan 6, 2019

Description

Checklist

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [$CATEGORY] (such as [Model], [Doc], [Feature]])
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented
  • To the my best knowledge, examples are either not affected by this change,
    or have been fixed to be compatible with this change
  • Related issue is referred in this PR

Changes

  • As requested in How can I implement the function dgl.max_nodes? #306 , a naive implementation for max readout on nodes and edges is provided with max_nodes and max_edges in batched_graph.py. A more efficient implementation will require segment_max. The test cases are provided in tests/pytorch/test_readout.py
  • As discussed in Creating DGLGraph from non-consecutive int nodes #334 , if we want to create a DGLGraph object from a networkx graph with non-consecutive node labels, we relabel the nodes using consecutive integers first before converting it into a DGLGraph. The changes are from_networkx in graph.py, graph_index.py, immutable_graph_index.py. The test cases are provided in tests/compute/test_basics.py.
  • In from_networkx of graph.py, I also convert the networkx graph to be directed first, otherwise only half of the DGLGraph edges will have features.

@yzh119
Copy link
Member

yzh119 commented Jan 6, 2019

@mufeili does the segment_max you mentioned similar to segment_sum in tensorflow?

@mufeili
Copy link
Member Author

mufeili commented Jan 6, 2019

@yzh119 Yeah, see doc and code. @HQ01 told me he's interested in doing it.

@yzh119
Copy link
Member

yzh119 commented Jan 6, 2019

i see, i've read the code before

@BarclayII
Copy link
Collaborator

I think later on we will need to replace the for loop in max_nodes etc with a custom op, e.g. scatter_max.

@mufeili
Copy link
Member Author

mufeili commented Jan 7, 2019

@BarclayII I agree, this is just a very naive workaround.

Copy link
Member

@jermainewang jermainewang left a comment

Choose a reason for hiding this comment

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

LGTM. Some minor comments.

python/dgl/graph.py Outdated Show resolved Hide resolved
python/dgl/graph.py Show resolved Hide resolved
python/dgl/graph.py Outdated Show resolved Hide resolved
python/dgl/graph.py Outdated Show resolved Hide resolved
@jermainewang
Copy link
Member

Great! Thanks Murphy.

@jermainewang jermainewang merged commit 3a868eb into dmlc:master Jan 10, 2019