• Returns the elements, either a or b depending on the condition.

    If the condition is true, select from a, otherwise select from b.

    const cond = tf.tensor1d([false, false, true], 'bool');
    const a = tf.tensor1d([1 , 2, 3]);
    const b = tf.tensor1d([-1, -2, -3]);

    a.where(cond, b).print();

    Type Parameters

    Parameters

    • condition: Tensor<Rank> | TensorLike

      The input condition. Must be of dtype bool.

    • a: TensorLike | T

      If condition is rank 1, a may have a higher rank but its first dimension must match the size of condition.

    • b: TensorLike | T

      A tensor with the same dtype as a and with shape that is compatible with a.

    Returns T

    A tensor with same dtype as a and b, and shape that is broadcastable from a and b.

    Doc

Generated using TypeDoc