mindspore_gl.HeterGraphField

查看源文件
class mindspore_gl.HeterGraphField(src_idx, dst_idx, n_nodes, n_edges)[源代码]

异构图的数据容器。

边信息以COO格式存储。

参数:
  • src_idx (List[Tensor]) - 包含Tensor的list,Tensor的shape为 \((N\_EDGES)\) 的int类型Tensor,表示COO边矩阵的源节点索引。

  • dst_idx (List[Tensor]) - 包含Tensor的list,Tensor的shape为 \((N\_EDGES)\) 的int类型Tensor,表示COO边矩阵的目标节点索引。

  • n_nodes (List[int]) - 由int组成的list,表示图中节点数量。

  • n_edges (List[int]) - 由int组成的list,表示图中边数量。

支持平台:

Ascend GPU

样例:

>>> import mindspore as ms
>>> from mindspore_gl import HeterGraphField
>>> n_nodes = [9, 2]
>>> n_edges = [11, 1]
>>> src_idx = [ms.Tensor([0, 2, 2, 3, 4, 5, 5, 6, 8, 8, 8], ms.int32), ms.Tensor([0], ms.int32)]
>>> dst_idx = [ms.Tensor([1, 0, 1, 5, 3, 4, 6, 4, 8, 8, 8], ms.int32), ms.Tensor([1], ms.int32)]
>>> heter_graph_field = HeterGraphField(src_idx, dst_idx, n_nodes, n_edges)
>>> print(heter_graph_field.get_heter_graph())
[[Tensor(shape=[11], dtype=Int32, value= [0, 2, 2, 3, 4, 5, 5, 6, 8, 8, 8]),
Tensor(shape=[1], dtype=Int32, value= [0])],
[Tensor(shape=[11], dtype=Int32, value= [1, 0, 1, 5, 3, 4, 6, 4, 8, 8, 8]),
Tensor(shape=[1], dtype=Int32, value= [1])], [9, 2], [11, 1]]
get_heter_graph()[源代码]

获取批次图。

返回:

List,Tensor的列表,被应用于构造函数。