View source on GitHub
|
Median of a tensor over the given axes, ignoring NaNs.
tf.keras.ops.nanmedian(
x, axis=None, keepdims=False
)
This function computes the median along the specified axis or axes, skipping any NaN values. If all values along a reduced axis are NaN, the result is NaN.
Returns | |
|---|---|
| Tensor with the median values, ignoring NaNs. |
Examples:
import numpy as npfrom keras import opsx = np.array([[1.0, np.nan, 3.0],[np.nan, 2.0, 1.0]])ops.nanmedian(x)1.5
ops.nanmedian(x, axis=1)array([2., 1.5])
ops.nanmedian(x, axis=1, keepdims=True)array([[2. ],[1.5]])
View source on GitHub