Unverified Commit fdbf5a0f authored by Mufei Li's avatar Mufei Li Committed by GitHub
Browse files

[DGL-Go][Doc] Update DGL-Go version to 0.0.2 and misc fix from bug bash (#4236)



* Update

* Update

* Update

* Update
Co-authored-by: default avatarUbuntu <ubuntu@ip-172-31-53-142.us-west-2.compute.internal>
Co-authored-by: default avatarXin Yao <xiny@nvidia.com>
parent 79b0a50a
version: 0.0.1 version: 0.0.2
pipeline_name: nodepred pipeline_name: nodepred
pipeline_mode: train pipeline_mode: train
device: cpu device: cpu
......
...@@ -439,7 +439,7 @@ class CoraGraphDataset(CitationGraphDataset): ...@@ -439,7 +439,7 @@ class CoraGraphDataset(CitationGraphDataset):
graph structure, node features and labels. graph structure, node features and labels.
- ``ndata['train_mask']`` mask for training node set - ``ndata['train_mask']``: mask for training node set
- ``ndata['val_mask']``: mask for validation node set - ``ndata['val_mask']``: mask for validation node set
- ``ndata['test_mask']``: mask for test node set - ``ndata['test_mask']``: mask for test node set
- ``ndata['feat']``: node feature - ``ndata['feat']``: node feature
...@@ -590,7 +590,7 @@ class CiteseerGraphDataset(CitationGraphDataset): ...@@ -590,7 +590,7 @@ class CiteseerGraphDataset(CitationGraphDataset):
graph structure, node features and labels. graph structure, node features and labels.
- ``ndata['train_mask']`` mask for training node set - ``ndata['train_mask']``: mask for training node set
- ``ndata['val_mask']``: mask for validation node set - ``ndata['val_mask']``: mask for validation node set
- ``ndata['test_mask']``: mask for test node set - ``ndata['test_mask']``: mask for test node set
- ``ndata['feat']``: node feature - ``ndata['feat']``: node feature
...@@ -738,7 +738,7 @@ class PubmedGraphDataset(CitationGraphDataset): ...@@ -738,7 +738,7 @@ class PubmedGraphDataset(CitationGraphDataset):
graph structure, node features and labels. graph structure, node features and labels.
- ``ndata['train_mask']`` mask for training node set - ``ndata['train_mask']``: mask for training node set
- ``ndata['val_mask']``: mask for validation node set - ``ndata['val_mask']``: mask for validation node set
- ``ndata['test_mask']``: mask for test node set - ``ndata['test_mask']``: mask for test node set
- ``ndata['feat']``: node feature - ``ndata['feat']``: node feature
......
...@@ -8,7 +8,6 @@ import traceback ...@@ -8,7 +8,6 @@ import traceback
import abc import abc
from .utils import download, extract_archive, get_download_dir, makedirs from .utils import download, extract_archive, get_download_dir, makedirs
from ..utils import retry_method_with_fix from ..utils import retry_method_with_fix
from .._ffi.base import __version__
class DGLDataset(object): class DGLDataset(object):
r"""The basic DGL dataset for creating graph datasets. r"""The basic DGL dataset for creating graph datasets.
...@@ -238,17 +237,13 @@ class DGLDataset(object): ...@@ -238,17 +237,13 @@ class DGLDataset(object):
def save_dir(self): def save_dir(self):
r"""Directory to save the processed dataset. r"""Directory to save the processed dataset.
""" """
return self._save_dir + "_v{}".format(__version__) return self._save_dir
@property @property
def save_path(self): def save_path(self):
r"""Path to save the processed dataset. r"""Path to save the processed dataset.
""" """
if hasattr(self, '_reorder'): return os.path.join(self._save_dir, self.name)
path = 'reordered' if self._reorder else 'un_reordered'
return os.path.join(self._save_dir, self.name, path)
else:
return os.path.join(self._save_dir, self.name)
@property @property
def verbose(self): def verbose(self):
......
...@@ -50,6 +50,7 @@ class FlickrDataset(DGLBuiltinDataset): ...@@ -50,6 +50,7 @@ class FlickrDataset(DGLBuiltinDataset):
Examples Examples
-------- --------
>>> from dgl.data import FlickrDataset
>>> dataset = FlickrDataset() >>> dataset = FlickrDataset()
>>> dataset.num_classes >>> dataset.num_classes
7 7
...@@ -151,9 +152,9 @@ class FlickrDataset(DGLBuiltinDataset): ...@@ -151,9 +152,9 @@ class FlickrDataset(DGLBuiltinDataset):
- ``ndata['label']``: node label - ``ndata['label']``: node label
- ``ndata['feat']``: node feature - ``ndata['feat']``: node feature
- ``ndata['train_mask']`` mask for training node set - ``ndata['train_mask']``: mask for training node set
- ``ndata['val_mask']``: mask for validation node set - ``ndata['val_mask']``: mask for validation node set
- ``ndata['test_mask']:`` mask for test node set - ``ndata['test_mask']``: mask for test node set
""" """
assert idx == 0, "This dataset has only one graph" assert idx == 0, "This dataset has only one graph"
......
...@@ -17,7 +17,6 @@ from .graph_serialize import save_graphs, load_graphs, load_labels ...@@ -17,7 +17,6 @@ from .graph_serialize import save_graphs, load_graphs, load_labels
from .tensor_serialize import save_tensors, load_tensors from .tensor_serialize import save_tensors, load_tensors
from .. import backend as F from .. import backend as F
from .._ffi.base import __version__
__all__ = ['loadtxt','download', 'check_sha1', 'extract_archive', __all__ = ['loadtxt','download', 'check_sha1', 'extract_archive',
'get_download_dir', 'Subset', 'split_dataset', 'save_graphs', 'get_download_dir', 'Subset', 'split_dataset', 'save_graphs',
...@@ -241,7 +240,7 @@ def get_download_dir(): ...@@ -241,7 +240,7 @@ def get_download_dir():
dirname : str dirname : str
Path to the download directory Path to the download directory
""" """
default_dir = os.path.join(os.path.expanduser('~'), '.dgl_v{}'.format(__version__)) default_dir = os.path.join(os.path.expanduser('~'), '.dgl')
dirname = os.environ.get('DGL_DOWNLOAD_DIR', default_dir) dirname = os.environ.get('DGL_DOWNLOAD_DIR', default_dir)
if not os.path.exists(dirname): if not os.path.exists(dirname):
os.makedirs(dirname) os.makedirs(dirname)
......
...@@ -50,6 +50,7 @@ class WikiCSDataset(DGLBuiltinDataset): ...@@ -50,6 +50,7 @@ class WikiCSDataset(DGLBuiltinDataset):
Examples Examples
-------- --------
>>> from dgl.data import WikiCSDataset
>>> dataset = WikiCSDataset() >>> dataset = WikiCSDataset()
>>> dataset.num_classes >>> dataset.num_classes
10 10
......
...@@ -151,9 +151,9 @@ class YelpDataset(DGLBuiltinDataset): ...@@ -151,9 +151,9 @@ class YelpDataset(DGLBuiltinDataset):
- ``ndata['label']``: node label - ``ndata['label']``: node label
- ``ndata['feat']``: node feature - ``ndata['feat']``: node feature
- ``ndata['train_mask']`` mask for training node set - ``ndata['train_mask']``: mask for training node set
- ``ndata['val_mask']``: mask for validation node set - ``ndata['val_mask']``: mask for validation node set
- ``ndata['test_mask']:`` mask for test node set - ``ndata['test_mask']``: mask for test node set
""" """
assert idx == 0, "This dataset has only one graph" assert idx == 0, "This dataset has only one graph"
......
...@@ -45,7 +45,7 @@ class EGATConv(nn.Module): ...@@ -45,7 +45,7 @@ class EGATConv(nn.Module):
num_heads : int num_heads : int
Number of attention heads. Number of attention heads.
bias : bool, optional bias : bool, optional
If True, add bias term to :math: `f_{ij}^{\prime}`. Defaults: ``True``. If True, add bias term to :math:`f_{ij}^{\prime}`. Defaults: ``True``.
Examples Examples
---------- ----------
...@@ -170,16 +170,16 @@ class EGATConv(nn.Module): ...@@ -170,16 +170,16 @@ class EGATConv(nn.Module):
Returns Returns
------- -------
pair of torch.Tensor pair of torch.Tensor
node output features followed by edge output features node output features followed by edge output features.
The node output feature of shape :math:`(N, H, D_{out})` The node output feature is of shape :math:`(N, H, D_{out})`
The edge output feature of shape :math:`(F, H, F_{out})` The edge output feature is of shape :math:`(F, H, F_{out})`
where: where:
:math:`H` is the number of heads, :math:`H` is the number of heads,
:math:`D_{out}` is size of output node feature, :math:`D_{out}` is size of output node feature,
:math:`F_{out}` is size of output edge feature. :math:`F_{out}` is size of output edge feature.
torch.Tensor, optional torch.Tensor, optional
The attention values of shape :math:`(E, H, 1)`. The attention values of shape :math:`(E, H, 1)`.
This is returned only when :attr: `get_attention` is ``True``. This is returned only when :attr:`get_attention` is ``True``.
""" """
with graph.local_scope(): with graph.local_scope():
......
...@@ -2872,6 +2872,8 @@ def sort_csr_by_tag(g, tag, tag_offset_name='_TAG_OFFSET', tag_type='node'): ...@@ -2872,6 +2872,8 @@ def sort_csr_by_tag(g, tag, tag_offset_name='_TAG_OFFSET', tag_type='node'):
``tag_type`` is ``node``. ``tag_type`` is ``node``.
>>> import dgl >>> import dgl
>>> import torch
>>> g = dgl.graph(([0,0,0,0,0,1,1,1],[0,1,2,3,4,0,1,2])) >>> g = dgl.graph(([0,0,0,0,0,1,1,1],[0,1,2,3,4,0,1,2]))
>>> g.adjacency_matrix(scipy_fmt='csr').nonzero() >>> g.adjacency_matrix(scipy_fmt='csr').nonzero()
(array([0, 0, 0, 0, 0, 1, 1, 1], dtype=int32), (array([0, 0, 0, 0, 0, 1, 1, 1], dtype=int32),
...@@ -2890,11 +2892,10 @@ def sort_csr_by_tag(g, tag, tag_offset_name='_TAG_OFFSET', tag_type='node'): ...@@ -2890,11 +2892,10 @@ def sort_csr_by_tag(g, tag, tag_offset_name='_TAG_OFFSET', tag_type='node'):
``tag_type`` is ``edge``. ``tag_type`` is ``edge``.
>>> from dgl import backend as F
>>> g = dgl.graph(([0,0,0,0,0,1,1,1],[0,1,2,3,4,0,1,2])) >>> g = dgl.graph(([0,0,0,0,0,1,1,1],[0,1,2,3,4,0,1,2]))
>>> g.edges() >>> g.edges()
(tensor([0, 0, 0, 0, 0, 1, 1, 1]), tensor([0, 1, 2, 3, 4, 0, 1, 2])) (tensor([0, 0, 0, 0, 0, 1, 1, 1]), tensor([0, 1, 2, 3, 4, 0, 1, 2]))
>>> tag = F.tensor([1, 1, 0, 2, 0, 1, 1, 0]) >>> tag = torch.tensor([1, 1, 0, 2, 0, 1, 1, 0])
>>> g_sorted = dgl.sort_csr_by_tag(g, tag, tag_type='edge') >>> g_sorted = dgl.sort_csr_by_tag(g, tag, tag_type='edge')
>>> g_sorted.adj(scipy_fmt='csr').nonzero() >>> g_sorted.adj(scipy_fmt='csr').nonzero()
(array([0, 0, 0, 0, 0, 1, 1, 1], dtype=int32), array([2, 4, 0, 1, 3, 2, 0, 1], dtype=int32)) (array([0, 0, 0, 0, 0, 1, 1, 1], dtype=int32), array([2, 4, 0, 1, 3, 2, 0, 1], dtype=int32))
...@@ -2995,6 +2996,7 @@ def sort_csc_by_tag(g, tag, tag_offset_name='_TAG_OFFSET', tag_type='node'): ...@@ -2995,6 +2996,7 @@ def sort_csc_by_tag(g, tag, tag_offset_name='_TAG_OFFSET', tag_type='node'):
``tag_type`` is ``node``. ``tag_type`` is ``node``.
>>> import dgl >>> import dgl
>>> import torch
>>> g = dgl.graph(([0,1,2,3,4,0,1,2],[0,0,0,0,0,1,1,1])) >>> g = dgl.graph(([0,1,2,3,4,0,1,2],[0,0,0,0,0,1,1,1]))
>>> g.adjacency_matrix(scipy_fmt='csr', transpose=True).nonzero() >>> g.adjacency_matrix(scipy_fmt='csr', transpose=True).nonzero()
(array([0, 0, 0, 0, 0, 1, 1, 1], dtype=int32), (array([0, 0, 0, 0, 0, 1, 1, 1], dtype=int32),
...@@ -3013,9 +3015,8 @@ def sort_csc_by_tag(g, tag, tag_offset_name='_TAG_OFFSET', tag_type='node'): ...@@ -3013,9 +3015,8 @@ def sort_csc_by_tag(g, tag, tag_offset_name='_TAG_OFFSET', tag_type='node'):
``tag_type`` is ``edge``. ``tag_type`` is ``edge``.
>>> from dgl import backend as F
>>> g = dgl.graph(([0,1,2,3,4,0,1,2],[0,0,0,0,0,1,1,1])) >>> g = dgl.graph(([0,1,2,3,4,0,1,2],[0,0,0,0,0,1,1,1]))
>>> tag = F.tensor([1, 1, 0, 2, 0, 1, 1, 0]) >>> tag = torch.tensor([1, 1, 0, 2, 0, 1, 1, 0])
>>> g_sorted = dgl.sort_csc_by_tag(g, tag, tag_type='edge') >>> g_sorted = dgl.sort_csc_by_tag(g, tag, tag_type='edge')
>>> g_sorted.adj(scipy_fmt='csr', transpose=True).nonzero() >>> g_sorted.adj(scipy_fmt='csr', transpose=True).nonzero()
(array([0, 0, 0, 0, 0, 1, 1, 1], dtype=int32), array([2, 4, 0, 1, 3, 2, 0, 1], dtype=int32)) (array([0, 0, 0, 0, 0, 1, 1, 1], dtype=int32), array([2, 4, 0, 1, 3, 2, 0, 1], dtype=int32))
......
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