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.train.RootMeanSquareDistance

View Source On Gitee
class mindspore.train.RootMeanSquareDistance(symmetric=False, distance_metric='euclidean')[source]

Computes the Root Mean Square Surface Distance from y_pred to y under the default setting.

Given two sets A and B, S(A) denotes the set of surface voxels of A, the shortest distance of an arbitrary voxel v to S(A) is defined as:

dis(v,S(A))=min sAS(A)vsA

The Root Mean Square Surface Distance from set(B) to set(A) is:

RmsSurDis(BA)=sBS(B)dis2(sB,S(A))|S(B)|

Where the ||*|| denotes a distance measure. |*| denotes the number of elements.

The Root Mean Square Surface Distance from set(B) to set(A) and from set(A) to set(B) is:

RmsSurDis(AB)=sAS(A)dis(sA,S(B))2+sBS(B)dis(sB,S(A))2|S(A)|+|S(B)|
Parameters
  • distance_metric (str) – Three measurement methods are supported: "euclidean" (Euclidean Distance) , "chessboard" (Chessboard Distance, Chebyshev Distance) or "taxicab" (Taxicab Distance, Manhattan Distance). Default: "euclidean" .

  • symmetric (bool) – Whether to calculate the symmetric average root mean square distance between y_pred and y. If False, only calculates RmsSurDis(y_pred,y) surface distance, otherwise, the mean of distance from y_pred to y and from y to y_pred, i.e. RmsSurDis(y_predy) will be returned. Default: False .

Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor
>>> from mindspore.train import RootMeanSquareDistance
>>>
>>> x = Tensor(np.array([[3, 0, 1], [1, 3, 0], [1, 0, 2]]))
>>> y = Tensor(np.array([[0, 2, 1], [1, 2, 1], [0, 0, 1]]))
>>> metric = RootMeanSquareDistance(symmetric=False, distance_metric="euclidean")
>>> metric.clear()
>>> metric.update(x, y, 0)
>>> root_mean_square_distance = metric.eval()
>>> print(root_mean_square_distance)
1.0000000000000002
clear()[source]

Clears the internal evaluation result.

eval()[source]

Calculate Root Mean Square Distance.

Returns

numpy.float64, root mean square surface distance.

Raises

RuntimeError – If the update method is not called first, an error will be reported.

update(*inputs)[source]

Updates the internal evaluation result 'y_pred', 'y' and 'label_idx'.

Parameters

inputs – Input 'y_pred', 'y' and 'label_idx'. 'y_pred' and 'y' are Tensor, list or numpy.ndarray. 'y_pred' is the predicted binary image. 'y' is the actual binary image. 'label_idx', the data type of label_idx is int.

Raises
  • ValueError – If the number of the inputs is not 3.

  • TypeError – If the data type of label_idx is not int or float.

  • ValueError – If the value of label_idx is not in y_pred or y.

  • ValueError – If y_pred and y have different shapes.