From fdbf5a0fdab16a945187b27452daf9aeedad5ebf Mon Sep 17 00:00:00 2001 From: Mufei Li Date: Thu, 14 Jul 2022 21:30:38 +0800 Subject: [PATCH] [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: Ubuntu Co-authored-by: Xin Yao --- dglgo/README.md | 6 +++--- dglgo/dglgo/utils/enter_config.py | 2 +- dglgo/recipes/graphpred_hiv_gin.yaml | 2 +- dglgo/recipes/graphpred_hiv_pna.yaml | 2 +- dglgo/recipes/graphpred_pcba_gin.yaml | 2 +- dglgo/recipes/linkpred_citation2_sage.yaml | 2 +- dglgo/recipes/linkpred_collab_sage.yaml | 2 +- dglgo/recipes/linkpred_cora_sage.yaml | 2 +- dglgo/recipes/nodepred-ns_arxiv_gcn.yaml | 2 +- dglgo/recipes/nodepred-ns_product_sage.yaml | 2 +- dglgo/recipes/nodepred_citeseer_gat.yaml | 2 +- dglgo/recipes/nodepred_citeseer_gcn.yaml | 2 +- dglgo/recipes/nodepred_citeseer_sage.yaml | 2 +- dglgo/recipes/nodepred_cora_gat.yaml | 2 +- dglgo/recipes/nodepred_cora_gcn.yaml | 2 +- dglgo/recipes/nodepred_cora_sage.yaml | 2 +- dglgo/recipes/nodepred_pubmed_gat.yaml | 2 +- dglgo/recipes/nodepred_pubmed_gcn.yaml | 2 +- dglgo/recipes/nodepred_pubmed_sage.yaml | 2 +- dglgo/setup.py | 2 +- dglgo/tests/cfg.yml | 2 +- python/dgl/data/citation_graph.py | 6 +++--- python/dgl/data/dgl_dataset.py | 9 ++------- python/dgl/data/flickr.py | 5 +++-- python/dgl/data/utils.py | 3 +-- python/dgl/data/wikics.py | 1 + python/dgl/data/yelp.py | 4 ++-- python/dgl/nn/pytorch/conv/egatconv.py | 10 +++++----- python/dgl/transforms/functional.py | 9 +++++---- 29 files changed, 45 insertions(+), 48 deletions(-) diff --git a/dglgo/README.md b/dglgo/README.md index e3e536f08069..cff2bc1913dc 100644 --- a/dglgo/README.md +++ b/dglgo/README.md @@ -61,7 +61,7 @@ Let's use one of the most classical setups -- training a GraphSAGE model for nod classification on the Cora citation graph dataset as an example. -### Step one: `dgl configure` +### Step 1: `dgl configure` First step, use `dgl configure` to generate a YAML configuration file. @@ -85,7 +85,7 @@ At this point you can also change options to explore optimization potentials. The snippet below shows the configuration file generated by the command above. ```yaml -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred pipeline_mode: train device: cpu @@ -181,7 +181,7 @@ That's all! Basically you only need two commands to train a graph neural network ### Step 3: `dgl export` for more advanced customization -That's not everything yet. You may want to open the hood and and invoke deeper +That's not everything yet. You may want to open the hood and invoke deeper customization. DGL-Go can export a **self-contained, reproducible** Python script for you to do anything you like. diff --git a/dglgo/dglgo/utils/enter_config.py b/dglgo/dglgo/utils/enter_config.py index 307b5a88543e..07a65eb13340 100644 --- a/dglgo/dglgo/utils/enter_config.py +++ b/dglgo/dglgo/utils/enter_config.py @@ -23,7 +23,7 @@ class PipelineConfig(DGLBaseModel): loss: str = "CrossEntropyLoss" class UserConfig(DGLBaseModel): - version: Optional[str] = "0.0.1" + version: Optional[str] = "0.0.2" pipeline_name: PipelineFactory.get_pipeline_enum() pipeline_mode: str device: str = "cpu" diff --git a/dglgo/recipes/graphpred_hiv_gin.yaml b/dglgo/recipes/graphpred_hiv_gin.yaml index b7f12435ce34..d809d93ddc1e 100644 --- a/dglgo/recipes/graphpred_hiv_gin.yaml +++ b/dglgo/recipes/graphpred_hiv_gin.yaml @@ -1,4 +1,4 @@ -version: 0.0.1 +version: 0.0.2 pipeline_name: graphpred pipeline_mode: train device: cuda:0 # Torch device name, e.q. cpu or cuda or cuda:0 diff --git a/dglgo/recipes/graphpred_hiv_pna.yaml b/dglgo/recipes/graphpred_hiv_pna.yaml index 4d65e88a1578..c67ba297666b 100644 --- a/dglgo/recipes/graphpred_hiv_pna.yaml +++ b/dglgo/recipes/graphpred_hiv_pna.yaml @@ -1,4 +1,4 @@ -version: 0.0.1 +version: 0.0.2 pipeline_name: graphpred pipeline_mode: train device: cuda:0 # Torch device name, e.q. cpu or cuda or cuda:0 diff --git a/dglgo/recipes/graphpred_pcba_gin.yaml b/dglgo/recipes/graphpred_pcba_gin.yaml index eeda45e5c147..e980f762e3de 100644 --- a/dglgo/recipes/graphpred_pcba_gin.yaml +++ b/dglgo/recipes/graphpred_pcba_gin.yaml @@ -1,4 +1,4 @@ -version: 0.0.1 +version: 0.0.2 pipeline_name: graphpred pipeline_mode: train device: cuda:0 # Torch device name, e.q. cpu or cuda or cuda:0 diff --git a/dglgo/recipes/linkpred_citation2_sage.yaml b/dglgo/recipes/linkpred_citation2_sage.yaml index 664d04c45fcf..c4ef3d08b82b 100644 --- a/dglgo/recipes/linkpred_citation2_sage.yaml +++ b/dglgo/recipes/linkpred_citation2_sage.yaml @@ -1,4 +1,4 @@ -version: 0.0.1 +version: 0.0.2 pipeline_name: linkpred pipeline_mode: train device: cpu diff --git a/dglgo/recipes/linkpred_collab_sage.yaml b/dglgo/recipes/linkpred_collab_sage.yaml index c4e85981c1cd..0d1418178a10 100644 --- a/dglgo/recipes/linkpred_collab_sage.yaml +++ b/dglgo/recipes/linkpred_collab_sage.yaml @@ -1,4 +1,4 @@ -version: 0.0.1 +version: 0.0.2 pipeline_name: linkpred pipeline_mode: train device: cpu diff --git a/dglgo/recipes/linkpred_cora_sage.yaml b/dglgo/recipes/linkpred_cora_sage.yaml index 487534d0d266..92f976bc574e 100644 --- a/dglgo/recipes/linkpred_cora_sage.yaml +++ b/dglgo/recipes/linkpred_cora_sage.yaml @@ -1,4 +1,4 @@ -version: 0.0.1 +version: 0.0.2 pipeline_name: linkpred pipeline_mode: train device: cuda diff --git a/dglgo/recipes/nodepred-ns_arxiv_gcn.yaml b/dglgo/recipes/nodepred-ns_arxiv_gcn.yaml index 49cf1a2c2caf..136cb38207f5 100644 --- a/dglgo/recipes/nodepred-ns_arxiv_gcn.yaml +++ b/dglgo/recipes/nodepred-ns_arxiv_gcn.yaml @@ -1,5 +1,5 @@ # Accuracy across 5 runs: 0.593288 ± 0.006103 -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred-ns pipeline_mode: train device: 'cuda:0' diff --git a/dglgo/recipes/nodepred-ns_product_sage.yaml b/dglgo/recipes/nodepred-ns_product_sage.yaml index 995e21139147..9ba9362bf620 100644 --- a/dglgo/recipes/nodepred-ns_product_sage.yaml +++ b/dglgo/recipes/nodepred-ns_product_sage.yaml @@ -1,5 +1,5 @@ # Accuracy across 1 runs: 0.796911 -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred-ns pipeline_mode: train device: cuda diff --git a/dglgo/recipes/nodepred_citeseer_gat.yaml b/dglgo/recipes/nodepred_citeseer_gat.yaml index 333903622a3a..7fd787b3016c 100644 --- a/dglgo/recipes/nodepred_citeseer_gat.yaml +++ b/dglgo/recipes/nodepred_citeseer_gat.yaml @@ -1,5 +1,5 @@ # Accuracy across 10 runs: 0.7097 ± 0.006914 -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred pipeline_mode: train device: cuda:0 diff --git a/dglgo/recipes/nodepred_citeseer_gcn.yaml b/dglgo/recipes/nodepred_citeseer_gcn.yaml index 1eccdc751efa..ae326006d338 100644 --- a/dglgo/recipes/nodepred_citeseer_gcn.yaml +++ b/dglgo/recipes/nodepred_citeseer_gcn.yaml @@ -1,5 +1,5 @@ # Accuracy across 10 runs: 0.6852 ± 0.008875 -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred pipeline_mode: train device: cuda:0 diff --git a/dglgo/recipes/nodepred_citeseer_sage.yaml b/dglgo/recipes/nodepred_citeseer_sage.yaml index b7995a06adf2..8c1fd1f7a85f 100644 --- a/dglgo/recipes/nodepred_citeseer_sage.yaml +++ b/dglgo/recipes/nodepred_citeseer_sage.yaml @@ -1,5 +1,5 @@ # Accuracy across 10 runs: 0.6994 ± 0.004005 -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred pipeline_mode: train device: cuda:0 diff --git a/dglgo/recipes/nodepred_cora_gat.yaml b/dglgo/recipes/nodepred_cora_gat.yaml index 04242ca192a9..3d71e160d35b 100644 --- a/dglgo/recipes/nodepred_cora_gat.yaml +++ b/dglgo/recipes/nodepred_cora_gat.yaml @@ -1,5 +1,5 @@ # Accuracy across 10 runs: 0.8208 ± 0.00663 -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred pipeline_mode: train device: cuda:0 diff --git a/dglgo/recipes/nodepred_cora_gcn.yaml b/dglgo/recipes/nodepred_cora_gcn.yaml index 838797868c6d..173f7df6e890 100644 --- a/dglgo/recipes/nodepred_cora_gcn.yaml +++ b/dglgo/recipes/nodepred_cora_gcn.yaml @@ -1,5 +1,5 @@ # Accuracy across 10 runs: 0.802 ± 0.005329 -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred pipeline_mode: train device: cuda:0 diff --git a/dglgo/recipes/nodepred_cora_sage.yaml b/dglgo/recipes/nodepred_cora_sage.yaml index 736f5a689e9b..de59943fb95d 100644 --- a/dglgo/recipes/nodepred_cora_sage.yaml +++ b/dglgo/recipes/nodepred_cora_sage.yaml @@ -1,5 +1,5 @@ # Accuracy across 10 runs: 0.8163 ± 0.006856 -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred pipeline_mode: train device: cuda:0 diff --git a/dglgo/recipes/nodepred_pubmed_gat.yaml b/dglgo/recipes/nodepred_pubmed_gat.yaml index 39c68da6e987..c0b511de6fe5 100644 --- a/dglgo/recipes/nodepred_pubmed_gat.yaml +++ b/dglgo/recipes/nodepred_pubmed_gat.yaml @@ -1,5 +1,5 @@ # Accuracy across 10 runs: 0.7788 ± 0.002227 -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred pipeline_mode: train device: cuda:0 diff --git a/dglgo/recipes/nodepred_pubmed_gcn.yaml b/dglgo/recipes/nodepred_pubmed_gcn.yaml index 557152a1156a..f83f6c7ee7ce 100644 --- a/dglgo/recipes/nodepred_pubmed_gcn.yaml +++ b/dglgo/recipes/nodepred_pubmed_gcn.yaml @@ -1,5 +1,5 @@ # Accuracy across 10 runs: 0.7826 ± 0.004317 -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred pipeline_mode: train device: cuda:0 diff --git a/dglgo/recipes/nodepred_pubmed_sage.yaml b/dglgo/recipes/nodepred_pubmed_sage.yaml index 4906507a37b3..8d4920c6a14e 100644 --- a/dglgo/recipes/nodepred_pubmed_sage.yaml +++ b/dglgo/recipes/nodepred_pubmed_sage.yaml @@ -1,5 +1,5 @@ # Accuracy across 10 runs: 0.7819 ± 0.003176 -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred pipeline_mode: train device: cuda:0 diff --git a/dglgo/setup.py b/dglgo/setup.py index 8e72464be76a..c64d85a8093d 100644 --- a/dglgo/setup.py +++ b/dglgo/setup.py @@ -4,7 +4,7 @@ from distutils.core import setup setup(name='dglgo', - version='0.0.1', + version='0.0.2', description='DGL', author='DGL Team', author_email='wmjlyjemaine@gmail.com', diff --git a/dglgo/tests/cfg.yml b/dglgo/tests/cfg.yml index dedc8c61f49b..bf6e1170b96b 100644 --- a/dglgo/tests/cfg.yml +++ b/dglgo/tests/cfg.yml @@ -1,4 +1,4 @@ -version: 0.0.1 +version: 0.0.2 pipeline_name: nodepred pipeline_mode: train device: cpu diff --git a/python/dgl/data/citation_graph.py b/python/dgl/data/citation_graph.py index a5c74a1c3084..350b2fb3ebe8 100644 --- a/python/dgl/data/citation_graph.py +++ b/python/dgl/data/citation_graph.py @@ -439,7 +439,7 @@ def __getitem__(self, idx): 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['test_mask']``: mask for test node set - ``ndata['feat']``: node feature @@ -590,7 +590,7 @@ def __getitem__(self, idx): 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['test_mask']``: mask for test node set - ``ndata['feat']``: node feature @@ -738,7 +738,7 @@ def __getitem__(self, idx): 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['test_mask']``: mask for test node set - ``ndata['feat']``: node feature diff --git a/python/dgl/data/dgl_dataset.py b/python/dgl/data/dgl_dataset.py index cf2edfa1da32..c1566935c1a7 100644 --- a/python/dgl/data/dgl_dataset.py +++ b/python/dgl/data/dgl_dataset.py @@ -8,7 +8,6 @@ import abc from .utils import download, extract_archive, get_download_dir, makedirs from ..utils import retry_method_with_fix -from .._ffi.base import __version__ class DGLDataset(object): r"""The basic DGL dataset for creating graph datasets. @@ -238,17 +237,13 @@ def raw_path(self): def save_dir(self): r"""Directory to save the processed dataset. """ - return self._save_dir + "_v{}".format(__version__) + return self._save_dir @property def save_path(self): r"""Path to save the processed dataset. """ - if hasattr(self, '_reorder'): - 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) + return os.path.join(self._save_dir, self.name) @property def verbose(self): diff --git a/python/dgl/data/flickr.py b/python/dgl/data/flickr.py index 4dd29a9b569b..97d92d441204 100644 --- a/python/dgl/data/flickr.py +++ b/python/dgl/data/flickr.py @@ -50,6 +50,7 @@ class FlickrDataset(DGLBuiltinDataset): Examples -------- + >>> from dgl.data import FlickrDataset >>> dataset = FlickrDataset() >>> dataset.num_classes 7 @@ -151,9 +152,9 @@ def __getitem__(self, idx): - ``ndata['label']``: node label - ``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['test_mask']:`` mask for test node set + - ``ndata['test_mask']``: mask for test node set """ assert idx == 0, "This dataset has only one graph" diff --git a/python/dgl/data/utils.py b/python/dgl/data/utils.py index 91d30617914f..339e3a65bd82 100644 --- a/python/dgl/data/utils.py +++ b/python/dgl/data/utils.py @@ -17,7 +17,6 @@ from .tensor_serialize import save_tensors, load_tensors from .. import backend as F -from .._ffi.base import __version__ __all__ = ['loadtxt','download', 'check_sha1', 'extract_archive', 'get_download_dir', 'Subset', 'split_dataset', 'save_graphs', @@ -241,7 +240,7 @@ def get_download_dir(): dirname : str 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) if not os.path.exists(dirname): os.makedirs(dirname) diff --git a/python/dgl/data/wikics.py b/python/dgl/data/wikics.py index b3d5c9868790..90c7ad9a8f39 100644 --- a/python/dgl/data/wikics.py +++ b/python/dgl/data/wikics.py @@ -50,6 +50,7 @@ class WikiCSDataset(DGLBuiltinDataset): Examples -------- + >>> from dgl.data import WikiCSDataset >>> dataset = WikiCSDataset() >>> dataset.num_classes 10 diff --git a/python/dgl/data/yelp.py b/python/dgl/data/yelp.py index 11a347b21c63..390c737be2b8 100644 --- a/python/dgl/data/yelp.py +++ b/python/dgl/data/yelp.py @@ -151,9 +151,9 @@ def __getitem__(self, idx): - ``ndata['label']``: node label - ``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['test_mask']:`` mask for test node set + - ``ndata['test_mask']``: mask for test node set """ assert idx == 0, "This dataset has only one graph" diff --git a/python/dgl/nn/pytorch/conv/egatconv.py b/python/dgl/nn/pytorch/conv/egatconv.py index e9009db0603d..682bdc90565e 100644 --- a/python/dgl/nn/pytorch/conv/egatconv.py +++ b/python/dgl/nn/pytorch/conv/egatconv.py @@ -45,7 +45,7 @@ class EGATConv(nn.Module): num_heads : int Number of attention heads. 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 ---------- @@ -170,16 +170,16 @@ def forward(self, graph, nfeats, efeats, get_attention=False): Returns ------- pair of torch.Tensor - node output features followed by edge output features - The node output feature of shape :math:`(N, H, D_{out})` - The edge output feature of shape :math:`(F, H, F_{out})` + node output features followed by edge output features. + The node output feature is of shape :math:`(N, H, D_{out})` + The edge output feature is of shape :math:`(F, H, F_{out})` where: :math:`H` is the number of heads, :math:`D_{out}` is size of output node feature, :math:`F_{out}` is size of output edge feature. torch.Tensor, optional 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(): diff --git a/python/dgl/transforms/functional.py b/python/dgl/transforms/functional.py index 1b0ac9934d14..725628d80431 100644 --- a/python/dgl/transforms/functional.py +++ b/python/dgl/transforms/functional.py @@ -2872,6 +2872,8 @@ def sort_csr_by_tag(g, tag, tag_offset_name='_TAG_OFFSET', tag_type='node'): ``tag_type`` is ``node``. >>> import dgl + >>> import torch + >>> 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() (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'): ``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.edges() (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.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)) @@ -2995,6 +2996,7 @@ def sort_csc_by_tag(g, tag, tag_offset_name='_TAG_OFFSET', tag_type='node'): ``tag_type`` is ``node``. >>> import dgl + >>> import torch >>> 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() (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'): ``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])) - >>> 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.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))