Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore_gl.graph.sampling_csr_data

View Source On Gitee
mindspore_gl.graph.sampling_csr_data(src_idx, dst_idx, n_nodes, n_edges, seeds_idx=None, node_feat=None, rerank=False)[source]

Convert the sampling graph in the COO format to the CSR format.

Parameters
  • src_idx (Union[Tensor, numpy.ndarray]) – tensor with shape (N_EDGES), with int dtype, represents the source node index of COO edge matrix.

  • dst_idx (Union[Tensor, numpy.ndarray]) – tensor with shape (N_EDGES), with int dtype, represents the destination node index of COO edge matrix.

  • n_nodes (int) – integer, represent the nodes count of the graph.

  • n_edges (int) – integer, represent the edges count of the graph.

  • seeds_idx (numpy.ndarray) – start nodes for neighbor sampling. Default: None.

  • node_feat (Union[Tensor, numpy.ndarray], optional) – node feature. Default: None.

  • rerank (bool, optional) – whether to reorder node features, node labels, and masks. Default: False.

Returns

  • csr_g (tuple) - info of csr graph, it contains indices of csr graph, indptr of csr graph, node numbers of csr graph, edges numbers of csr graph, pre-stored backward indices of csr graph, pre-stored backward indptr of csr graph.

  • seeds_idx (numpy.ndarray) - reordered start nodes.

  • node_feat (numpy.ndarray) - reorder node features.

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> from mindspore_gl.graph import sampling_csr_data
>>> node_feat = np.array([[1, 2, 3, 4], [2, 4, 1, 3], [1, 3, 2, 4],
...                       [9, 7, 5, 8], [8, 7, 6, 5], [8, 6, 4, 6], [1, 2, 1, 1]], np.float32)
>>> n_nodes = 7
>>> n_edges = 8
>>> edge_feat_size = 7
>>> src_idx = np.array([0, 2, 2, 3, 4, 5, 5, 6], np.int32)
>>> dst_idx = np.array([1, 0, 1, 5, 3, 4, 6, 4], np.int32)
>>> seeds_idx = np.array([0, 3, 5])
>>> g, seeds_idx, node_feat = sampling_csr_data(src_idx, dst_idx, n_nodes, n_edges,\
...                                             seeds_idx, node_feat, rerank=True)
>>> print(g[0], g[1], seeds_idx)
[2 3 5 6 3 4 0 6] [0 2 4 5 6 7 8 8] [5, 4, 3]
>>> print(node_feat)
[[8. 7. 6. 5.]
 [2. 4. 1. 3.]
 [1. 2. 1. 1.]
 [8. 6. 4. 6.]
 [9. 7. 5. 8.]
 [1. 2. 3. 4.]
 [1. 3. 2. 4.]]