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.norm

View Source On Gitee
mindspore_gl.graph.norm(edge_index, num_nodes, edge_weight=None, normalization='sym', lambda_max=None, batch=None)[source]

graph laplacian normalization.

Parameters
  • edge_index (Tensor) – Edge index. The shape is (2,N_e) where N_e is the number of edges.

  • num_nodes (int) – Number of nodes.

  • edge_weight (Tensor) – Edge weights. The shape is (N_e) where N_e is the number of edges. Default: None.

  • normalization (str) –

    Normalization method. Default: 'sym'. (L) is normalized matrix, (D) is degree matrix, (A) is adjaceny matrix, (I) is unit matrix.

    1. None: No normalization L=DA

    2. 'sym': Symmetric normalization L=ID1/2AD1/2

    3. 'rw': Random-walk normalization L=ID1A

  • lambda_max (int, float) – Lambda value of graph. Default: None.

  • batch (Tensor) – Batch vector. Default: None.

Returns

  • edge_index (Tensor) - normalized edge_index.

  • edge_weight (Tensor) - normalized edge_weight

Raises

ValueError – if normalization not is None or 'sym' or 'rw'.

Supported Platforms:

Ascend GPU

Examples

>>> import mindspore as ms
>>> from mindspore_gl.graph import norm
>>> edge_index = [[1, 1, 2, 2], [0, 2, 0, 1]]
>>> edge_index = ms.Tensor(edge_index, ms.int32)
>>> num_nodes = 3
>>> edge_index, edge_weight = norm(edge_index, num_nodes)
>>> print(edge_index)
[[1 1 2 2 0 1 2]
 [0 2 0 1 0 1 2]]
>>> print(edge_weight)
[-0.        -0.4999999 -0.        -0.4999999  1.         1.
  1.       ]