mindspore.nn.RootMeanSquareDistance
- class mindspore.nn.RootMeanSquareDistance(symmetric=False, distance_metric="euclidean")[source]
This function is used to compute the Residual Mean Square Distance from y_pred to y under the default setting. Residual Mean Square Distance(RMS), the mean is taken from each of the points in the vector, these residuals are squared (to remove negative signs), summed, weighted by the mean and then the square-root is taken. Measured in mm.
- Parameters
distance_metric (string) – The parameter of calculating Hausdorff distance supports three measurement methods, “euclidean”, “chessboard” or “taxicab”. Default: “euclidean”.
symmetric (bool) – if calculate the symmetric average surface distance between y_pred and y. In addition, if sets
symmetric = True
, the average symmetric surface distance between these two inputs will be returned. Default: False.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> from mindspore import nn, Tensor >>> >>> 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 = nn.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
- eval()[source]
Calculate residual mean square surface distance.
- Returns
A float with residual 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 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.