mindspore_gl.BatchedGraphField

查看源文件
class mindspore_gl.BatchedGraphField(src_idx=None, dst_idx=None, n_nodes=None, n_edges=None, ver_subgraph_idx=None, edge_subgraph_idx=None, graph_mask=None, indices=None, indptr=None, indices_backward=None, indptr_backward=None, csr=False)[源代码]

批次图的数据容器。

边信息以COO格式存储。

参数:
  • src_idx (Tensor, 可选) - shape为 \((N\_EDGES)\) 的int类型Tensor,表示COO边矩阵的源节点索引。默认值:None

  • dst_idx (Tensor, 可选) - shape为 \((N\_EDGES)\) 的int类型Tensor,表示COO边矩阵的目标节点索引。默认值:None

  • n_nodes (int, 可选) - 图中节点数量。默认值:None

  • n_edges (int, 可选) - 图中边数量。默认值:None

  • ver_subgraph_idx (Tensor, 可选) - shape为 \((N\_NODES)\) 的int类型Tensor,指示每个节点属于哪个子图。默认值:None

  • edge_subgraph_idx (Tensor, 可选) - shape为 \((N\_NODES,)\) 的int类型Tensor,指示每个边属于哪个子图。默认值:None

  • graph_mask (Tensor, 可选) - shape为 \((N\_GRAPHS,)\) 的int类型Tensor,表示子图是否存在。默认值:None

  • indices (Tensor, 可选) - shape为 \((N\_EDGES)\) 的int类型Tensor,CSR矩阵中的indices。默认值:None

  • indptr (Tensor, 可选) - shape为 \((N\_NODES,)\) 的int类型Tensor,CSR矩阵中的indptr。默认值:None

  • indices_backward (Tensor, 可选) - shape为 \((N\_EDGES)\) 的int类型Tensor,CSR矩阵中的预存的indices反向。默认值:None

  • indptr_backward (Tensor, 可选) - shape为 \((N\_NODES,)\) 的int类型Tensor,CSR矩阵中的预存的indptr反向。默认值:None

  • csr (bool, 可选) - 是否为CSR类型。默认值:False

支持平台:

Ascend GPU

样例:

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

获取批次图。

返回:

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