I have a tensor:
tensor = tf.convert_to_tensor(np.array([[0, 1, 2, 3, 4, np.nan],
[6, 7, 8, 9, 10, 11]]))
and would like to drop the row that has nan. For instance:
<tf.Tensor: shape=(6,), dtype=int64, numpy=array([ 6, 7, 8, 9, 10, 11])>
How do you do this in TensorFlow?
CodePudding user response:
This code will remove nan rows:
tensor[~np.isnan(tensor).any(axis=1)]