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

Update (#2354)

parent 061c2a36
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
The nodes and edges of a :class:`~dgl.DGLGraph` can have several user-defined named features for The nodes and edges of a :class:`~dgl.DGLGraph` can have several user-defined named features for
storing graph-specific properties of the nodes and edges. These features can be accessed storing graph-specific properties of the nodes and edges. These features can be accessed
via the :py:attr:`~dgl.DGLGraph.ndata` and :py:attr:`~dgl.DGLGraph.edata` interface. For example, the following code creates two node via the :py:attr:`~dgl.DGLGraph.ndata` and :py:attr:`~dgl.DGLGraph.edata` interface. For example, the following code creates two node
features (named ``'x'`` and ``'y'`` in line 5 and 8) and one edge feature (named ``'x'`` in line 6). features (named ``'x'`` and ``'y'`` in line 8 and 15) and one edge feature (named ``'x'`` in line 9).
.. code-block:: python .. code-block:: python
:linenos: :linenos:
...@@ -45,7 +45,7 @@ Important facts about the :py:attr:`~dgl.DGLGraph.ndata`/:py:attr:`~dgl.DGLGraph ...@@ -45,7 +45,7 @@ Important facts about the :py:attr:`~dgl.DGLGraph.ndata`/:py:attr:`~dgl.DGLGraph
nodes/edges in the graph. nodes/edges in the graph.
- Features of the same name must have the same dimensionality and data type. - Features of the same name must have the same dimensionality and data type.
- The feature tensor is in row-major layout -- each row-slice stores the feature of one - The feature tensor is in row-major layout -- each row-slice stores the feature of one
node or edge (e.g., see lines 10-11 in the above example). node or edge (e.g., see lines 16 and 18 in the above example).
For weighted graphs, one can store the weights as an edge feature as below. For weighted graphs, one can store the weights as an edge feature as below.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
:class:`~dgl.DGLGraph` 对象的节点和边可具有多个用户定义的、可命名的特征,以储存图的节点和边的属性。 :class:`~dgl.DGLGraph` 对象的节点和边可具有多个用户定义的、可命名的特征,以储存图的节点和边的属性。
通过 :py:attr:`~dgl.DGLGraph.ndata` 和 :py:attr:`~dgl.DGLGraph.edata` 接口可访问这些特征。 通过 :py:attr:`~dgl.DGLGraph.ndata` 和 :py:attr:`~dgl.DGLGraph.edata` 接口可访问这些特征。
例如,以下代码创建了2个节点特征(分别在第5、8行命名为 ``'x'`` 、 ``'y'`` )和1个边特征(在第6行命名为 ``'x'`` )。 例如,以下代码创建了2个节点特征(分别在第8、15行命名为 ``'x'`` 、 ``'y'`` )和1个边特征(在第9行命名为 ``'x'`` )。
.. code-block:: python .. code-block:: python
:linenos: :linenos:
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
- 通过张量分配创建特征时,DGL会将特征赋给图中的每个节点和每条边。该张量的第一维必须与图中节点或边的数量一致。 - 通过张量分配创建特征时,DGL会将特征赋给图中的每个节点和每条边。该张量的第一维必须与图中节点或边的数量一致。
不能将特征赋给图中节点或边的子集。 不能将特征赋给图中节点或边的子集。
- 相同名称的特征必须具有相同的维度和数据类型。 - 相同名称的特征必须具有相同的维度和数据类型。
- 特征张量使用"行优先"的原则,即每个行切片储存1个节点或1条边的特征(参考上述示例代码的第10~11行)。 - 特征张量使用"行优先"的原则,即每个行切片储存1个节点或1条边的特征(参考上述示例代码的第16和18行)。
对于加权图,用户可以将权重储存为一个边特征,如下。 对于加权图,用户可以将权重储存为一个边特征,如下。
......
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