Unverified Commit 2d689235 authored by Mingbang Wang's avatar Mingbang Wang Committed by GitHub
Browse files

[Misc] Update comments in python code (#6551)

parent 16033d12
...@@ -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`.
""" """
############################################################################ ############################################################################
......
...@@ -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
......
...@@ -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]),
......
...@@ -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))
......
...@@ -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]))
""" """
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment