Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
2d689235
Unverified
Commit
2d689235
authored
Nov 09, 2023
by
Mingbang Wang
Committed by
GitHub
Nov 09, 2023
Browse files
[Misc] Update comments in python code (#6551)
parent
16033d12
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
25 deletions
+22
-25
examples/sampling/graphbolt/link_prediction.py
examples/sampling/graphbolt/link_prediction.py
+2
-1
examples/sampling/graphbolt/node_classification.py
examples/sampling/graphbolt/node_classification.py
+2
-1
python/dgl/graphbolt/impl/fused_csc_sampling_graph.py
python/dgl/graphbolt/impl/fused_csc_sampling_graph.py
+3
-4
python/dgl/graphbolt/impl/neighbor_sampler.py
python/dgl/graphbolt/impl/neighbor_sampler.py
+11
-13
python/dgl/graphbolt/impl/uniform_negative_sampler.py
python/dgl/graphbolt/impl/uniform_negative_sampler.py
+4
-6
No files found.
examples/sampling/graphbolt/link_prediction.py
View file @
2d689235
...
@@ -83,7 +83,8 @@ def create_dataloader(args, graph, features, itemset, is_train=True):
...
@@ -83,7 +83,8 @@ def create_dataloader(args, graph, features, itemset, is_train=True):
"""Get a GraphBolt version of a dataloader for link prediction tasks. This
"""Get a GraphBolt version of a dataloader for link prediction tasks. This
function demonstrates how to utilize functional forms of datapipes in
function demonstrates how to utilize functional forms of datapipes in
GraphBolt. Alternatively, you can create a datapipe using its class
GraphBolt. Alternatively, you can create a datapipe using its class
constructor.
constructor. For a more detailed tutorial, please read the examples in
`dgl/notebooks/graphbolt/walkthrough.ipynb`.
"""
"""
############################################################################
############################################################################
...
...
examples/sampling/graphbolt/node_classification.py
View file @
2d689235
...
@@ -56,7 +56,8 @@ def create_dataloader(
...
@@ -56,7 +56,8 @@ def create_dataloader(
[HIGHLIGHT]
[HIGHLIGHT]
Get a GraphBolt version of a dataloader for node classification tasks.
Get a GraphBolt version of a dataloader for node classification tasks.
This function demonstrates how to utilize functional forms of datapipes in
This function demonstrates how to utilize functional forms of datapipes in
GraphBolt.
GraphBolt. For a more detailed tutorial, please read the examples in
`dgl/notebooks/graphbolt/walkthrough.ipynb`.
Alternatively, you can create a datapipe using its class constructor.
Alternatively, you can create a datapipe using its class constructor.
Parameters
Parameters
...
...
python/dgl/graphbolt/impl/fused_csc_sampling_graph.py
View file @
2d689235
...
@@ -772,7 +772,6 @@ def from_fused_csc(
...
@@ -772,7 +772,6 @@ def from_fused_csc(
... node_type_offset=node_type_offset,
... node_type_offset=node_type_offset,
... type_per_edge=type_per_edge,
... type_per_edge=type_per_edge,
... edge_attributes=None, metadata=metadata)
... edge_attributes=None, metadata=metadata)
None, metadata)
>>> print(graph)
>>> print(graph)
FusedCSCSamplingGraph(csc_indptr=tensor([0, 2, 5, 7]),
FusedCSCSamplingGraph(csc_indptr=tensor([0, 2, 5, 7]),
indices=tensor([1, 3, 0, 1, 2, 0, 3]),
indices=tensor([1, 3, 0, 1, 2, 0, 3]),
...
...
python/dgl/graphbolt/impl/neighbor_sampler.py
View file @
2d689235
...
@@ -63,12 +63,11 @@ class NeighborSampler(SubgraphSampler):
...
@@ -63,12 +63,11 @@ class NeighborSampler(SubgraphSampler):
>>> node_pairs = torch.LongTensor([[0, 1], [1, 2]])
>>> node_pairs = torch.LongTensor([[0, 1], [1, 2]])
>>> item_set = gb.ItemSet(node_pairs, names="node_pairs")
>>> item_set = gb.ItemSet(node_pairs, names="node_pairs")
>>> item_sampler = gb.ItemSampler(
>>> item_sampler = gb.ItemSampler(
...item_set, batch_size=1,
... item_set, batch_size=1,)
...)
>>> neg_sampler = gb.UniformNegativeSampler(
>>> neg_sampler = gb.UniformNegativeSampler(
...
item_sampler, graph, 2)
...
item_sampler, graph, 2)
>>> subgraph_sampler = gb.NeighborSampler(
>>> subgraph_sampler = gb.NeighborSampler(
...
neg_sampler, graph, [5, 10, 15])
...
neg_sampler, graph, [5, 10, 15])
>>> for data in subgraph_sampler:
>>> for data in subgraph_sampler:
... print(data.compacted_node_pairs)
... print(data.compacted_node_pairs)
... print(len(data.sampled_subgraphs))
... print(len(data.sampled_subgraphs))
...
@@ -197,14 +196,13 @@ class LayerNeighborSampler(NeighborSampler):
...
@@ -197,14 +196,13 @@ class LayerNeighborSampler(NeighborSampler):
>>> node_pairs = torch.LongTensor([[0, 1], [1, 2]])
>>> node_pairs = torch.LongTensor([[0, 1], [1, 2]])
>>> item_set = gb.ItemSet(node_pairs, names="node_pairs")
>>> item_set = gb.ItemSet(node_pairs, names="node_pairs")
>>> item_sampler = gb.ItemSampler(
>>> item_sampler = gb.ItemSampler(
...item_set, batch_size=1,
... item_set, batch_size=1,)
...)
>>> neg_sampler = gb.UniformNegativeSampler(
>>> neg_sampler = gb.UniformNegativeSampler(
...
item_sampler, 2, data_format, graph)
...
item_sampler, 2, data_format, graph)
>>> fanouts = [torch.LongTensor([5]), torch.LongTensor([10]),
>>> fanouts = [torch.LongTensor([5]), torch.LongTensor([10]),
...
torch.LongTensor([15])]
...
torch.LongTensor([15])]
>>> subgraph_sampler = gb.LayerNeighborSampler(
>>> subgraph_sampler = gb.LayerNeighborSampler(
...
neg_sampler, graph, fanouts)
...
neg_sampler, graph, fanouts)
>>> for data in subgraph_sampler:
>>> for data in subgraph_sampler:
... print(data.compacted_node_pairs)
... print(data.compacted_node_pairs)
... print(len(data.sampled_subgraphs))
... print(len(data.sampled_subgraphs))
...
...
python/dgl/graphbolt/impl/uniform_negative_sampler.py
View file @
2d689235
...
@@ -36,14 +36,12 @@ class UniformNegativeSampler(NegativeSampler):
...
@@ -36,14 +36,12 @@ class UniformNegativeSampler(NegativeSampler):
>>> node_pairs = (torch.tensor([0, 1]), torch.tensor([1, 2]))
>>> node_pairs = (torch.tensor([0, 1]), torch.tensor([1, 2]))
>>> item_set = gb.ItemSet(node_pairs, names="node_pairs")
>>> item_set = gb.ItemSet(node_pairs, names="node_pairs")
>>> item_sampler = gb.ItemSampler(
>>> item_sampler = gb.ItemSampler(
...item_set, batch_size=1,
... item_set, batch_size=1,)
...)
>>> neg_sampler = gb.UniformNegativeSampler(
>>> neg_sampler = gb.UniformNegativeSampler(
...
item_sampler, graph, 2)
...
item_sampler, graph, 2)
>>> for minibatch in neg_sampler:
>>> for minibatch in neg_sampler:
... print(minibatch.negative_srcs)
... print(minibatch.negative_srcs)
... print(minibatch.negative_dsts)
... print(minibatch.negative_dsts)
...
(tensor([0, 0, 0]), tensor([1, 1, 2]), tensor([1, 0, 0]))
(tensor([0, 0, 0]), tensor([1, 1, 2]), tensor([1, 0, 0]))
(tensor([1, 1, 1]), tensor([2, 1, 2]), tensor([1, 0, 0]))
(tensor([1, 1, 1]), tensor([2, 1, 2]), tensor([1, 0, 0]))
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment