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
Hide 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):
"""Get a GraphBolt version of a dataloader for link prediction tasks. This
function demonstrates how to utilize functional forms of datapipes in
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(
[HIGHLIGHT]
Get a GraphBolt version of a dataloader for node classification tasks.
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.
Parameters
...
...
python/dgl/graphbolt/impl/fused_csc_sampling_graph.py
View file @
2d689235
...
...
@@ -143,15 +143,15 @@ class FusedCSCSamplingGraph(SamplingGraph):
>>> total_num_edges = 12
>>> ntypes = {"N0": 0, "N1": 1}
>>> etypes = {"N0:R0:N0": 0, "N0:R1:N1": 1,
... "N1:R2:N0": 2, "N1:R3:N1": 3}
...
"N1:R2:N0": 2, "N1:R3:N1": 3}
>>> indptr = torch.LongTensor([0, 3, 5, 7, 9, 12])
>>> indices = torch.LongTensor([0, 1, 4, 2, 3, 0, 1, 1, 2, 0, 3, 4])
>>> node_type_offset = torch.LongTensor([0, 2, 5])
>>> type_per_edge = torch.LongTensor(
... [0, 0, 2, 2, 2, 1, 1, 1, 3, 1, 3, 3])
...
[0, 0, 2, 2, 2, 1, 1, 1, 3, 1, 3, 3])
>>> metadata = gb.GraphMetadata(ntypes, etypes)
>>> graph = gb.from_fused_csc(indptr, indices, node_type_offset,
... type_per_edge, None, metadata)
...
type_per_edge, None, metadata)
>>> print(graph.num_nodes)
{'N0': 2, 'N1': 3}
"""
...
...
@@ -772,7 +772,6 @@ def from_fused_csc(
... node_type_offset=node_type_offset,
... type_per_edge=type_per_edge,
... edge_attributes=None, metadata=metadata)
None, metadata)
>>> print(graph)
FusedCSCSamplingGraph(csc_indptr=tensor([0, 2, 5, 7]),
indices=tensor([1, 3, 0, 1, 2, 0, 3]),
...
...
python/dgl/graphbolt/impl/neighbor_sampler.py
View file @
2d689235
...
...
@@ -63,15 +63,14 @@ class NeighborSampler(SubgraphSampler):
>>> node_pairs = torch.LongTensor([[0, 1], [1, 2]])
>>> item_set = gb.ItemSet(node_pairs, names="node_pairs")
>>> item_sampler = gb.ItemSampler(
...item_set, batch_size=1,
...)
... item_set, batch_size=1,)
>>> neg_sampler = gb.UniformNegativeSampler(
...
item_sampler, graph, 2)
...
item_sampler, graph, 2)
>>> subgraph_sampler = gb.NeighborSampler(
...
neg_sampler, graph, [5, 10, 15])
...
neg_sampler, graph, [5, 10, 15])
>>> for data in subgraph_sampler:
...
print(data.compacted_node_pairs)
...
print(len(data.sampled_subgraphs))
...
print(data.compacted_node_pairs)
...
print(len(data.sampled_subgraphs))
(tensor([0, 0, 0]), tensor([1, 0, 2]))
3
(tensor([0, 0, 0]), tensor([1, 1, 1]))
...
...
@@ -197,17 +196,16 @@ class LayerNeighborSampler(NeighborSampler):
>>> node_pairs = torch.LongTensor([[0, 1], [1, 2]])
>>> item_set = gb.ItemSet(node_pairs, names="node_pairs")
>>> item_sampler = gb.ItemSampler(
...item_set, batch_size=1,
...)
... item_set, batch_size=1,)
>>> neg_sampler = gb.UniformNegativeSampler(
...
item_sampler, 2, data_format, graph)
...
item_sampler, 2, data_format, graph)
>>> fanouts = [torch.LongTensor([5]), torch.LongTensor([10]),
...
torch.LongTensor([15])]
...
torch.LongTensor([15])]
>>> subgraph_sampler = gb.LayerNeighborSampler(
...
neg_sampler, graph, fanouts)
...
neg_sampler, graph, fanouts)
>>> for data in subgraph_sampler:
...
print(data.compacted_node_pairs)
...
print(len(data.sampled_subgraphs))
...
print(data.compacted_node_pairs)
...
print(len(data.sampled_subgraphs))
(tensor([0, 0, 0]), tensor([1, 0, 2]))
3
(tensor([0, 0, 0]), tensor([1, 1, 1]))
...
...
python/dgl/graphbolt/impl/uniform_negative_sampler.py
View file @
2d689235
...
...
@@ -36,14 +36,12 @@ class UniformNegativeSampler(NegativeSampler):
>>> node_pairs = (torch.tensor([0, 1]), torch.tensor([1, 2]))
>>> item_set = gb.ItemSet(node_pairs, names="node_pairs")
>>> item_sampler = gb.ItemSampler(
...item_set, batch_size=1,
...)
... item_set, batch_size=1,)
>>> neg_sampler = gb.UniformNegativeSampler(
...
item_sampler, graph, 2)
...
item_sampler, graph, 2)
>>> for minibatch in neg_sampler:
... print(minibatch.negative_srcs)
... print(minibatch.negative_dsts)
...
... print(minibatch.negative_srcs)
... print(minibatch.negative_dsts)
(tensor([0, 0, 0]), tensor([1, 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