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
b10b541c
"tests/git@developer.sourcefind.cn:OpenDAS/apex.git" did not exist on "896ecdd6df44deaf208b529c483b5bc8a118af45"
Unverified
Commit
b10b541c
authored
Sep 10, 2020
by
Quan (Andy) Gan
Committed by
GitHub
Sep 10, 2020
Browse files
fix multiple docstring inconsistencies (#2167)
parent
45b610c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
python/dgl/dataloading/dataloader.py
python/dgl/dataloading/dataloader.py
+7
-7
python/dgl/transform.py
python/dgl/transform.py
+9
-2
No files found.
python/dgl/dataloading/dataloader.py
View file @
b10b541c
...
...
@@ -299,7 +299,7 @@ class NodeCollator(Collator):
a homogeneous graph where each node takes messages from all neighbors (assume
the backend is PyTorch):
>>> sampler = dgl.dataloading.NeighborSampler([
None, None, None
])
>>> sampler = dgl.dataloading.
MultiLayer
NeighborSampler([
15, 10, 5
])
>>> collator = dgl.dataloading.NodeCollator(g, train_nid, sampler)
>>> dataloader = torch.utils.data.DataLoader(
... collator.dataset, collate_fn=collator.collate,
...
...
@@ -460,9 +460,9 @@ class EdgeCollator(Collator):
computation dependencies of the incident nodes. This is a common trick to avoid
information leakage.
>>> sampler = dgl.dataloading.NeighborSampler([
None, None, None
])
>>> sampler = dgl.dataloading.
MultiLayer
NeighborSampler([
15, 10, 5
])
>>> collator = dgl.dataloading.EdgeCollator(
... g, train_eid, sampler, exclude='reverse',
... g, train_eid, sampler, exclude='reverse
_id
',
... reverse_eids=reverse_eids)
>>> dataloader = torch.utils.data.DataLoader(
... collator.dataset, collate_fn=collator.collate,
...
...
@@ -474,10 +474,10 @@ class EdgeCollator(Collator):
homogeneous graph where each node takes messages from all neighbors (assume the
backend is PyTorch), with 5 uniformly chosen negative samples per edge:
>>> sampler = dgl.dataloading.NeighborSampler([
None, None, None
])
>>> sampler = dgl.dataloading.
MultiLayer
NeighborSampler([
15, 10, 5
])
>>> neg_sampler = dgl.dataloading.negative_sampler.Uniform(5)
>>> collator = dgl.dataloading.EdgeCollator(
... g, train_eid, sampler, exclude='reverse',
... g, train_eid, sampler, exclude='reverse
_id
',
... reverse_eids=reverse_eids, negative_sampler=neg_sampler,
>>> dataloader = torch.utils.data.DataLoader(
... collator.dataset, collate_fn=collator.collate,
...
...
@@ -498,7 +498,7 @@ class EdgeCollator(Collator):
To train a 3-layer GNN for edge classification on a set of edges ``train_eid`` with
type ``click``, you can write
>>> sampler = dgl.dataloading.NeighborSampler([
None, None, None
])
>>> sampler = dgl.dataloading.
MultiLayer
NeighborSampler([
15, 10, 5
])
>>> collator = dgl.dataloading.EdgeCollator(
... g, {'click': train_eid}, sampler, exclude='reverse_types',
... reverse_etypes={'click': 'clicked-by', 'clicked-by': 'click'})
...
...
@@ -511,7 +511,7 @@ class EdgeCollator(Collator):
To train a 3-layer GNN for link prediction on a set of edges ``train_eid`` with type
``click``, you can write
>>> sampler = dgl.dataloading.NeighborSampler([
None, None, None
])
>>> sampler = dgl.dataloading.
MultiLayer
NeighborSampler([
15, 10, 5
])
>>> neg_sampler = dgl.dataloading.negative_sampler.Uniform(5)
>>> collator = dgl.dataloading.EdgeCollator(
... g, train_eid, sampler, exclude='reverse_types',
...
...
python/dgl/transform.py
View file @
b10b541c
...
...
@@ -1632,7 +1632,7 @@ def to_block(g, dst_nodes=None, include_dst_in_src=True):
Examples
--------
Converting a homogeneous graph to a block as described above:
>>> g = dgl.graph(([
0,
1, 2], [
1,
2, 3]))
>>> g = dgl.graph(([1, 2], [2, 3]))
>>> block = dgl.to_block(g, torch.LongTensor([3, 2]))
The output nodes would be exactly the same as the ones given: [3, 2].
...
...
@@ -1665,10 +1665,17 @@ def to_block(g, dst_nodes=None, include_dst_in_src=True):
>>> induced_src[src], induced_dst[dst]
(tensor([2, 1]), tensor([3, 2]))
The output nodes specified must be a superset of the nodes that have edges connecting
to them. For example, the following will raise an error since the output nodes
does not contain node 3, which has an edge connecting to it.
>>> g = dgl.graph(([1, 2], [2, 3]))
>>> dgl.to_block(g, torch.LongTensor([2])) # error
Converting a heterogeneous graph to a block is similar, except that when specifying
the output nodes, you have to give a dict:
>>> g = dgl.heterograph({('A', '_E', 'B'): ([
0,
1, 2], [
1,
2, 3])})
>>> g = dgl.heterograph({('A', '_E', 'B'): ([1, 2], [2, 3])})
If you don't specify any node of type A on the output side, the node type ``A``
in the block would have zero nodes on the output side.
...
...
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