mlnext.score.l2_norm#
- mlnext.score.l2_norm(x: ndarray, x_hat: ndarray, *, reduce: bool = True) ndarray [source]#
Calculates the l2-norm (euclidean distance) for x and x_hat. If reduce is False, then the l2_norm is calculated feature-wise.
- Parameters:
x (np.ndarray) – ground truth.
x_hat (np.ndarray) – prediction.
- Returns:
Returns the l2-norm between x and x_hat.
- Return type:
np.ndarray
Example
>>> l2_norm(np.array([0.1, 0.2]), np.array([0.14, 0.2])) np.ndarray([[0.04]]) >>> l2_norm(np.array([0.1, 0.2]), np.array([0.14, 0.2]), reduce=False) np.ndarray([0.04, 0.0])