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
7ba9cbc6
Unverified
Commit
7ba9cbc6
authored
May 19, 2020
by
Quan (Andy) Gan
Committed by
GitHub
May 19, 2020
Browse files
[Docs] Fix docstrings and documentations (#1420)
* fix docs of to_block * fix * oops * more fixes
parent
e3793a5c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
7 deletions
+43
-7
docs/source/api/python/data.rst
docs/source/api/python/data.rst
+1
-1
docs/source/api/python/index.rst
docs/source/api/python/index.rst
+1
-0
docs/source/api/python/sampling.rst
docs/source/api/python/sampling.rst
+32
-0
python/dgl/sampling/pinsage.py
python/dgl/sampling/pinsage.py
+3
-0
python/dgl/transform.py
python/dgl/transform.py
+6
-6
No files found.
docs/source/api/python/data.rst
View file @
7ba9cbc6
...
@@ -246,7 +246,7 @@ Dataset Classes
...
@@ -246,7 +246,7 @@ Dataset Classes
If your dataset is stored in a ``.csv`` file, you may find it helpful to use
If your dataset is stored in a ``.csv`` file, you may find it helpful to use
.. autoclass:: dgl.data.chem.CSVDataset
.. autoclass:: dgl.data.chem.
Molecule
CSVDataset
:members: __getitem__, __len__
:members: __getitem__, __len__
Currently four datasets are supported:
Currently four datasets are supported:
...
...
docs/source/api/python/index.rst
View file @
7ba9cbc6
...
@@ -15,6 +15,7 @@ API Reference
...
@@ -15,6 +15,7 @@ API Reference
propagate
propagate
udf
udf
sampler
sampler
sampling
data
data
transform
transform
graph_store
graph_store
...
...
docs/source/api/python/sampling.rst
0 → 100644
View file @
7ba9cbc6
.. _api-sampling:
dgl.sampling
=================================
.. automodule:: dgl.sampling
Sampling algorithms on graphs.
Random walk sampling functions
------------------------------
.. autosummary::
:toctree: ../../generated/
random_walk
pack_traces
Neighbor sampling functions
---------------------------
.. autosummary::
:toctree: ../../generated/
sample_neighbors
select_topk
Builtin sampler classes for more complicated sampling algorithms
----------------------------------------------------------------
.. autoclass:: RandomWalkNeighborSampler
.. autoclass:: PinSAGESampler
python/dgl/sampling/pinsage.py
View file @
7ba9cbc6
...
@@ -178,6 +178,7 @@ class PinSAGESampler(RandomWalkNeighborSampler):
...
@@ -178,6 +178,7 @@ class PinSAGESampler(RandomWalkNeighborSampler):
Examples
Examples
--------
--------
Generate a random bidirectional bipartite graph with 3000 "A" nodes and 5000 "B" nodes.
Generate a random bidirectional bipartite graph with 3000 "A" nodes and 5000 "B" nodes.
>>> g = scipy.sparse.random(3000, 5000, 0.003)
>>> g = scipy.sparse.random(3000, 5000, 0.003)
>>> G = dgl.heterograph({
>>> G = dgl.heterograph({
... ('A', 'AB', 'B'): g,
... ('A', 'AB', 'B'): g,
...
@@ -185,10 +186,12 @@ class PinSAGESampler(RandomWalkNeighborSampler):
...
@@ -185,10 +186,12 @@ class PinSAGESampler(RandomWalkNeighborSampler):
Then we create a PinSAGE neighbor sampler that samples a graph of node type "A". Each
Then we create a PinSAGE neighbor sampler that samples a graph of node type "A". Each
node would have (a maximum of) 10 neighbors.
node would have (a maximum of) 10 neighbors.
>>> sampler = dgl.sampling.PinSAGESampler(G, 'A', 'B', 3, 0.5, 200, 10)
>>> sampler = dgl.sampling.PinSAGESampler(G, 'A', 'B', 3, 0.5, 200, 10)
This is how we select the neighbors for node #0, #1 and #2 of type "A" according to
This is how we select the neighbors for node #0, #1 and #2 of type "A" according to
PinSAGE algorithm:
PinSAGE algorithm:
>>> seeds = torch.LongTensor([0, 1, 2])
>>> seeds = torch.LongTensor([0, 1, 2])
>>> frontier = sampler(seeds)
>>> frontier = sampler(seeds)
>>> frontier.all_edges(form='uv')
>>> frontier.all_edges(form='uv')
...
...
python/dgl/transform.py
View file @
7ba9cbc6
...
@@ -884,21 +884,21 @@ def to_block(g, dst_nodes=None, include_dst_in_src=True):
...
@@ -884,21 +884,21 @@ def to_block(g, dst_nodes=None, include_dst_in_src=True):
>>> g = dgl.bipartite([(0, 1), (1, 2), (2, 3)], utype='A', vtype='B')
>>> g = dgl.bipartite([(0, 1), (1, 2), (2, 3)], utype='A', vtype='B')
If you don't specify any node of type A on the right hand side, the node type ``A``
If you don't specify any node of type A on the right hand side, the node type ``A``
in the block would have zero nodes.
in the block would have zero nodes
on the DST side
.
>>> block = dgl.to_block(g, {'B': torch.LongTensor([3, 2])})
>>> block = dgl.to_block(g, {'B': torch.LongTensor([3, 2])})
>>> block.number_of_nodes('A')
>>> block.number_of_
dst_
nodes('A')
0
0
>>> block.number_of_nodes('B')
>>> block.number_of_
dst_
nodes('B')
2
2
>>> block.nodes['B'].data[dgl.NID]
>>> block.
dst
nodes['B'].data[dgl.NID]
tensor([3, 2])
tensor([3, 2])
The left hand side would contain all the nodes on the right hand side:
The left hand side would contain all the nodes on the right hand side:
>>> block.nodes['B'].data[dgl.NID]
>>> block.
src
nodes['B'].data[dgl.NID]
tensor([3, 2])
tensor([3, 2])
As well as all the nodes that have connections to the nodes on the right hand side:
As well as all the nodes that have connections to the nodes on the right hand side:
>>> block.nodes['A'].data[dgl.NID]
>>> block.
src
nodes['A'].data[dgl.NID]
tensor([2, 1])
tensor([2, 1])
"""
"""
if
dst_nodes
is
None
:
if
dst_nodes
is
None
:
...
...
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