"git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "39764da491326c56d306882fb8af89f62cec2981"
Commit 6106a99d authored by RhettYing's avatar RhettYing
Browse files

refine

parent 3b49370d
...@@ -18,7 +18,10 @@ Base Dataset Class ...@@ -18,7 +18,10 @@ Base Dataset Class
.. autoclass:: DGLDataset .. autoclass:: DGLDataset
:members: download, save, load, process, has_cache, __getitem__, __len__ :members: download, save, load, process, has_cache, __getitem__, __len__
.. autoclass:: DGLCSVDataset CSV Dataset Class
-----------------
.. autoclass:: CSVDataset
Node Prediction Datasets Node Prediction Datasets
--------------------------------------- ---------------------------------------
......
...@@ -171,8 +171,8 @@ for edges: ...@@ -171,8 +171,8 @@ for edges:
3,0,False,True,False,"0.9784264442230887, 0.22131880861864428, 0.3161154827254189" 3,0,False,True,False,"0.9784264442230887, 0.22131880861864428, 0.3161154827254189"
4,1,True,True,False,"0.23142237259162102, 0.8715767748481147, 0.19117861103555467" 4,1,True,True,False,"0.23142237259162102, 0.8715767748481147, 0.19117861103555467"
After loaded, the dataset has one graph. Node/edge features are stored in ```ndata`` and ``edata`` After loaded, the dataset has one graph. Node/edge features are stored in ``ndata`` and ``edata``
with the same column names. The example demonstrates how to specify a vector-shaped feature -- with the same column names. The example demonstrates how to specify a vector-shaped feature
using comma-separated list enclosed by double quotes ``"..."``. using comma-separated list enclosed by double quotes ``"..."``.
.. code:: python .. code:: python
...@@ -378,18 +378,14 @@ After loaded, the dataset has multiple homographs with features and labels: ...@@ -378,18 +378,14 @@ After loaded, the dataset has multiple homographs with features and labels:
ndata_schemes={'feat': Scheme(shape=(3,), dtype=torch.float64)} ndata_schemes={'feat': Scheme(shape=(3,), dtype=torch.float64)}
edata_schemes={'feat': Scheme(shape=(3,), dtype=torch.float64)}) edata_schemes={'feat': Scheme(shape=(3,), dtype=torch.float64)})
>>> print(data0) >>> print(data0)
{'feat': tensor([0.7426, 0.5197, 0.8149]), 'label': tensor([0])} {'feat': tensor([0.7426, 0.5197, 0.8149], dtype=torch.float64), 'label': tensor(0)}
>>> graph1, data1 = dataset[1] >>> graph1, data1 = dataset[1]
>>> print(graph1) >>> print(graph1)
Graph(num_nodes=5, num_edges=10, Graph(num_nodes=5, num_edges=10,
ndata_schemes={'feat': Scheme(shape=(3,), dtype=torch.float64)} ndata_schemes={'feat': Scheme(shape=(3,), dtype=torch.float64)}
edata_schemes={'feat': Scheme(shape=(3,), dtype=torch.float64)}) edata_schemes={'feat': Scheme(shape=(3,), dtype=torch.float64)})
>>> print(data1) >>> print(data1)
{'feat': tensor([0.5348, 0.2864, 0.1155]), 'label': tensor([0])} {'feat': tensor([0.5348, 0.2864, 0.1155], dtype=torch.float64), 'label': tensor(0)}
.. note::
When there are multiple graphs, ``CSVDataset`` currently requires them to be homogeneous.
Custom Data Parser Custom Data Parser
...@@ -469,10 +465,11 @@ To parse the string type labels, one can define a ``DataParser`` class as follow ...@@ -469,10 +465,11 @@ To parse the string type labels, one can define a ``DataParser`` class as follow
parsed[header] = dt parsed[header] = dt
return parsed return parsed
Create a ``CSVDataset`` using the defined ``DataParser``: Create a ``CSVDataset`` using the defined ``DataParser``:
.. code:: python .. code:: python
>>> import dgl
>>> dataset = dgl.data.CSVDataset('./customized_parser_dataset', >>> dataset = dgl.data.CSVDataset('./customized_parser_dataset',
... ndata_parser=MyDataParser(), ... ndata_parser=MyDataParser(),
... edata_parser=MyDataParser()) ... edata_parser=MyDataParser())
...@@ -483,7 +480,7 @@ To parse the string type labels, one can define a ``DataParser`` class as follow ...@@ -483,7 +480,7 @@ To parse the string type labels, one can define a ``DataParser`` class as follow
.. note:: .. note::
To specify different ``DataParser`` s for different node/edge types, pass a dictionary to To specify different ``DataParser``\s for different node/edge types, pass a dictionary to
``ndata_parser`` and ``edata_parser``, where the key is type name (a single string for ``ndata_parser`` and ``edata_parser``, where the key is type name (a single string for
node type; a string triplet for edge type) and the value is the ``DataParser`` to use. node type; a string triplet for edge type) and the value is the ``DataParser`` to use.
......
...@@ -6,8 +6,7 @@ from ..base import DGLError ...@@ -6,8 +6,7 @@ from ..base import DGLError
class CSVDataset(DGLDataset): class CSVDataset(DGLDataset):
""" This class aims to parse data from CSV files, construct DGLGraph """Dataset class that loads and parses graph data from CSV files.
and behaves as a DGLDataset.
Parameters Parameters
---------- ----------
...@@ -52,11 +51,7 @@ class CSVDataset(DGLDataset): ...@@ -52,11 +51,7 @@ class CSVDataset(DGLDataset):
Examples Examples
-------- --------
``meta.yaml`` and CSV files are under ``csv_dir``. Please refer to :ref:`guide-data-pipeline-loadcsv`.
>>> csv_dataset = dgl.data.DGLCSVDataset(csv_dir)
See more details in :ref:`guide-data-pipeline-loadcsv`.
""" """
META_YAML_NAME = 'meta.yaml' META_YAML_NAME = 'meta.yaml'
......
...@@ -226,12 +226,10 @@ print(graph, label) ...@@ -226,12 +226,10 @@ print(graph, label)
# Creating Dataset from CSV via :class:`~dgl.data.DGLCSVDataset` # Creating Dataset from CSV via :class:`~dgl.data.DGLCSVDataset`
# ------------------------------------------------------------ # ------------------------------------------------------------
# #
# In the previous examples, dataset is created directly from raw CSV # The previous examples describe how to create a dataset from CSV files
# files via :class:`~dgl.data.DGLDataset`. DGL provides utility class # step-by-step. DGL also provides a utility class :class:`~dgl.data.CSVDataset`
# :class:`~dgl.data.DGLCSVDataset` to read data from CSV files and # for reading and parsing data from CSV files. See :ref:`guide-data-pipeline-loadcsv`
# construct :class:`~dgl.DGLGraph` more flexibly. Please refer to # for more details.
# :ref:`guide-data-pipeline-loadcsv` and see if this utility is more
# suitable for your case.
# #
......
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